From 8a47d0d0a742302898c4dcf177971db059887d12 Mon Sep 17 00:00:00 2001 From: zhengjihao <2714499297@qq.com> Date: Thu, 7 Aug 2025 19:34:52 +0800 Subject: [PATCH 1/5] fix: fix popup mouse leave event handler type and logic --- src/index.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index dafeee78..40433af0 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -568,7 +568,7 @@ export function generateTrigger( const hoverToHide = hideActions.has('hover'); let onPopupMouseEnter: React.MouseEventHandler; - let onPopupMouseLeave: VoidFunction; + let onPopupMouseLeave: React.MouseEventHandler; const ignoreMouseTrigger = () => { return touchedRef.current; @@ -629,8 +629,11 @@ export function generateTrigger( ignoreMouseTrigger, ); - onPopupMouseLeave = () => { - triggerOpen(false, mouseLeaveDelay); + onPopupMouseLeave = (event: React.MouseEvent) => { + // only trigger close when mouse leave popup + if (popupEle?.contains(event.target as HTMLElement)) { + triggerOpen(false, mouseLeaveDelay); + } }; } From 2b7290c5d8814b7e823bb903ce2c9cf5252c72c6 Mon Sep 17 00:00:00 2001 From: zhengjihao <2714499297@qq.com> Date: Fri, 8 Aug 2025 21:12:32 +0800 Subject: [PATCH 2/5] fix: Fixed onPopupMouseLeave triggering error --- src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index 40433af0..1e0646e8 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -630,7 +630,7 @@ export function generateTrigger( ); onPopupMouseLeave = (event: React.MouseEvent) => { - // only trigger close when mouse leave popup + // fix issue: https://github.com/ant-design/ant-design/issues/54496 if (popupEle?.contains(event.target as HTMLElement)) { triggerOpen(false, mouseLeaveDelay); } From 5884b91969714baf3385afe55fa415ef4b29d5cd Mon Sep 17 00:00:00 2001 From: zhengjihao <2714499297@qq.com> Date: Fri, 8 Aug 2025 21:14:16 +0800 Subject: [PATCH 3/5] fix: Fixed onPopupMouseLeave triggering error --- src/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index 1e0646e8..896f802b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -596,7 +596,8 @@ export function generateTrigger( ); onPopupMouseEnter = (event) => { - // Only trigger re-open when popup is visible + // Only trigger re-open when popup is visible or in motion + // and ensure the mouse is entering the popup area if ( (mergedOpen || inMotion) && popupEle?.contains(event.target as HTMLElement) From 6f0f2b94573e8ed2750d10bf733128336dbb7281 Mon Sep 17 00:00:00 2001 From: zhengjihao <2714499297@qq.com> Date: Thu, 14 Aug 2025 22:30:32 +0800 Subject: [PATCH 4/5] fix: refactor popup mouse event handling logic --- src/index.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 896f802b..b1e94b1f 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -576,6 +576,8 @@ export function generateTrigger( if (hoverToShow) { const onMouseEnterCallback = (event: React.MouseEvent) => { + // Clear any delayed close operations + clearDelay(); setMousePosByEvent(event); }; @@ -596,6 +598,9 @@ export function generateTrigger( ); onPopupMouseEnter = (event) => { + // Always clear the delay to ensure the mouse returns to the menu to cancel the close + clearDelay(); + // Only trigger re-open when popup is visible or in motion // and ensure the mouse is entering the popup area if ( @@ -630,11 +635,8 @@ export function generateTrigger( ignoreMouseTrigger, ); - onPopupMouseLeave = (event: React.MouseEvent) => { - // fix issue: https://github.com/ant-design/ant-design/issues/54496 - if (popupEle?.contains(event.target as HTMLElement)) { - triggerOpen(false, mouseLeaveDelay); - } + onPopupMouseLeave = () => { + triggerOpen(false, mouseLeaveDelay); }; } From d3468e389214430843417d445a9c0ad9418966c7 Mon Sep 17 00:00:00 2001 From: zhengjihao <2714499297@qq.com> Date: Thu, 14 Aug 2025 22:34:24 +0800 Subject: [PATCH 5/5] fix: update type of onPopupMouseLeave handler --- src/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index b1e94b1f..b6bf433b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -568,7 +568,7 @@ export function generateTrigger( const hoverToHide = hideActions.has('hover'); let onPopupMouseEnter: React.MouseEventHandler; - let onPopupMouseLeave: React.MouseEventHandler; + let onPopupMouseLeave: VoidFunction; const ignoreMouseTrigger = () => { return touchedRef.current;