Skip to content

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

editor: hide hover popup on editor destroy

Abdullah Attad31194bb3964
diff --git a/packages/editor/src/toolbar/floating-menus/hover-popup/index.tsx b/packages/editor/src/toolbar/floating-menus/hover-popup/index.tsx
index f12deab63..878ceae1a 100644
--- a/packages/editor/src/toolbar/floating-menus/hover-popup/index.tsx
+++ b/packages/editor/src/toolbar/floating-menus/hover-popup/index.tsx
@@ -38,6 +38,16 @@ export function HoverPopupHandler(props: FloatingMenuProps) {
const hoverTimeoutId = useRef<number>();
const activePopup = useRef<{ element: HTMLElement; hide: () => void }>();
+ useEffect(() => {
+ function onDestroy() {
+ activePopup.current?.hide();
+ }
+ editor.on("destroy", onDestroy);
+ return () => {
+ editor.off("destroy", onDestroy);
+ };
+ }, []);
+
useEffect(
() => {
function onMouseOver(e: MouseEvent) {