From 1f5164660d2aa0ffa01c3fd24f4c6223acff8d31 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Sat, 9 Mar 2024 22:56:44 +0500 Subject: [PATCH] editor: hide hover popup on editor destroy --- .../src/toolbar/floating-menus/hover-popup/index.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) 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(); 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) {