Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix: rect-popup event bind error (#1922)

zhangwac17c692b1de
diff --git a/packages/design/src/components/popup/RectPopup.tsx b/packages/design/src/components/popup/RectPopup.tsx
index 58afc5d8d9..0268bb1ea2 100644
--- a/packages/design/src/components/popup/RectPopup.tsx
+++ b/packages/design/src/components/popup/RectPopup.tsx
@@ -112,9 +112,11 @@ function RectPopup(props: IRectPopupProps) {
]);
useEffect(() => {
- const parent = nodeRef.current?.parentElement;
+ const current = nodeRef.current;
+ const parent = current?.parentElement;
+
if (parent) {
- const handleClick = (e: MouseEvent) => {
+ const handleClickOther = (e: MouseEvent) => {
if (excludeOutside && (excludeOutside.indexOf(e.target as any) > -1)) {
return;
}
@@ -127,10 +129,11 @@ function RectPopup(props: IRectPopupProps) {
}
clickOtherFn(e);
};
- parent.addEventListener('click', handleClick);
+
+ window.addEventListener('click', handleClickOther);
return () => {
- parent.removeEventListener('click', handleClick);
+ window.removeEventListener('click', handleClickOther);
};
}
}, [anchorRect, anchorRect.bottom, anchorRect.left, anchorRect.right, anchorRect.top, clickOtherFn, excludeOutside]);