mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-29 00:20:04 +01:00
editor: don't open already opened popup again
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user