Skip to content

Commit 6f0f2b9

Browse files
committed
fix: refactor popup mouse event handling logic
1 parent 5884b91 commit 6f0f2b9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/index.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,8 @@ export function generateTrigger(
576576

577577
if (hoverToShow) {
578578
const onMouseEnterCallback = (event: React.MouseEvent) => {
579+
// Clear any delayed close operations
580+
clearDelay();
579581
setMousePosByEvent(event);
580582
};
581583

@@ -596,6 +598,9 @@ export function generateTrigger(
596598
);
597599

598600
onPopupMouseEnter = (event) => {
601+
// Always clear the delay to ensure the mouse returns to the menu to cancel the close
602+
clearDelay();
603+
599604
// Only trigger re-open when popup is visible or in motion
600605
// and ensure the mouse is entering the popup area
601606
if (
@@ -630,11 +635,8 @@ export function generateTrigger(
630635
ignoreMouseTrigger,
631636
);
632637

633-
onPopupMouseLeave = (event: React.MouseEvent) => {
634-
// fix issue: https://github.com/ant-design/ant-design/issues/54496
635-
if (popupEle?.contains(event.target as HTMLElement)) {
636-
triggerOpen(false, mouseLeaveDelay);
637-
}
638+
onPopupMouseLeave = () => {
639+
triggerOpen(false, mouseLeaveDelay);
638640
};
639641
}
640642

0 commit comments

Comments
 (0)