editor: don't open already opened popup again

This commit is contained in:
ammarahm-ed
2022-09-13 11:54:33 +05:00
parent 881771a14f
commit df50ece50d
2 changed files with 5 additions and 1 deletions

View File

@@ -253,7 +253,7 @@ export function PopupWrapper(props: PopupWrapperProps) {
}, [autoCloseOnUnmount, id, PopupRenderer]);
useEffect(() => {
if (PopupRenderer && isPopupOpen) {
if (PopupRenderer && isPopupOpen && !PopupRenderer.isOpen(id)) {
PopupRenderer.openPopup(id, function Popup({ id }) {
const isPopupOpen = useToolbarStore(
(store) => !!store.openedPopups[id]

View File

@@ -40,6 +40,10 @@ export class PopupRenderer extends React.Component<
popups: [] as PopupRendererState["popups"]
};
isOpen(id: string) {
return !!this.state.popups?.find((popup) => popup.id === id);
}
openPopup = (id: string, popup: PopupComponent) => {
if (!popup) return;
this.setState((prev) => {