Skip to content

Conversation

@xshuxin
Copy link

@xshuxin xshuxin commented Jan 21, 2026

PR description

此 PR 修复了嵌套 Dropdown 场景下,点击子菜单项会导致父级 Dropdown 意外关闭的问题。

问题原因: 点击子菜单时, mousedown 事件会冒泡到 window ,触发了父级 Dropdown 绑定在 window 上的 onClickOutside 监听器,导致父级被误判为“外部点击”而关闭。

修复方案: 在 Dropdown 的内容容器(content wrapper)上监听 mousedown 事件,并调用 e.nativeEvent.stopImmediatePropagation() 阻止事件冒泡,从而避免触发父级的关闭逻辑。此修改已通过回归测试,并验证了对多级嵌套场景的有效性。

Fixes #3118

🇨🇳 Chinese

  • Fix: 修复嵌套 Dropdown 点击子菜单项时,父级菜单会意外关闭导致点击事件丢失的问题

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 4ab6708:

Sandbox Source
pr-story Configuration

@SudoUserReal
Copy link
Collaborator

这会改变现在的行为,更推荐添加一个开关来开关这个PR的逻辑来保证兼容性

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] [Dropdown] 嵌套 Dropdown 点击子菜单触发父级 onClickOutSide,导致子菜单 onClick 事件丢失

2 participants