Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: fix react error on feature dialog

Abdullah Atta422c2492c4a2
diff --git a/apps/web/src/components/dialog/index.tsx b/apps/web/src/components/dialog/index.tsx
index 2a4f22a59..7fe46edd5 100644
--- a/apps/web/src/components/dialog/index.tsx
+++ b/apps/web/src/components/dialog/index.tsx
@@ -232,6 +232,7 @@ function onAfterOpen(
e: ReactModal.OnAfterOpenCallbackOptions | undefined,
props: DialogProps
) {
+ if (props.onOpen) props.onOpen();
if (!props.onClose || !e) return;
// we need this work around because ReactModal content spreads over the overlay
const child = e.contentEl.firstElementChild as HTMLElement;
@@ -248,5 +249,4 @@ function onAfterOpen(
if (props.onClose) props.onClose();
}
};
- if (props.onOpen) props.onOpen();
}
diff --git a/apps/web/src/dialogs/feature-dialog.tsx b/apps/web/src/dialogs/feature-dialog.tsx
index 2c2c85033..63968bce1 100644
--- a/apps/web/src/dialogs/feature-dialog.tsx
+++ b/apps/web/src/dialogs/feature-dialog.tsx
@@ -147,12 +147,7 @@ export const FeatureDialog = DialogManager.register(function FeatureDialog(
) {
const { featureName, onClose } = props;
const feature = features[featureName];
-
- useEffect(() => {
- if (!feature || (feature.shouldShow && !feature.shouldShow())) {
- onClose(false);
- }
- }, [feature, onClose]);
+ const isShown = feature && feature.shouldShow && feature.shouldShow();
return (
<Dialog
@@ -160,6 +155,9 @@ export const FeatureDialog = DialogManager.register(function FeatureDialog(
title={feature.title}
description={feature.subtitle}
textAlignment="center"
+ onOpen={() => {
+ if (!isShown) onClose(false);
+ }}
positiveButton={{
text: (
<Flex>