Skip to content

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

Open
xshuxin wants to merge 2 commits intoDouyinFE:mainfrom
xshuxin:fix/dropdown-nested-click
Open

fix: 修复了嵌套 Dropdown 点击子菜单项时,父级菜单会意外关闭导致点击事件丢失的问题#3119
xshuxin wants to merge 2 commits intoDouyinFE:mainfrom
xshuxin:fix/dropdown-nested-click

Conversation

@xshuxin
Copy link

@xshuxin xshuxin commented Jan 21, 2026

PR description

在排查嵌套 Dropdown 问题时,发现如果错误地向 Dropdown 传递了 content 属性(通常是 Tooltip 的用法),该属性会通过 ...attr 透传给底层的 Tooltip,从而覆盖掉 Dropdown 内部生成的 pop 内容(包含 Context 和嵌套逻辑)。这会导致嵌套菜单的交互失效(如点击子菜单导致父级意外关闭)。

此 PR 调整了 Dropdown 中 Tooltip 组件的属性顺序,确保内部生成的 content={pop} 始终位于 ...attr 之后,即使开发者错误使用了 content 属性,Dropdown 也能保持内部逻辑的正确性,提高组件的健壮性。

修复方案:

🇨🇳 Chinese

  • Fix: 修复 Dropdown 内部 content 被透传属性误覆盖的问题

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 21, 2026

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 919cb48:

Sandbox Source
pr-story Configuration

@SudoUserReal
Copy link
Collaborator

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

@xshuxin
Copy link
Author

xshuxin commented Feb 4, 2026

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

刚刚重新验证了一下,发现是自己用法错误导致出现该问题,错误使用了content,然而实际上 content 会直接透传到 tooltip ,Dropdown 本身用 render 生成了带 Context 的内容,传 content 会覆盖它,导致嵌套相关的处理失效,换回 render 就正常了。

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