fix(Popup): keep popups open for shadow DOM interactions - #6980
Merged
Merged
Conversation
liweijie0812
requested review from
Cat1007,
PengYYYYY,
Wesley-0808,
chaishi,
uyarn,
zhangpaopao0609 and
zydemail
as code owners
September 23, 2026 05:09
Contributor
|
Size Change: 0 B Total Size: 3.55 kB ℹ️ View Unchanged
|
Collaborator
TDesign Component Site Preview Open
|
Contributor
|
Size Change: 0 B Total Size: 100 kB ℹ️ View Unchanged
|
commit: |
Contributor
|
Size Change: +284 B (+0.03%) Total Size: 963 kB 📦 View Changed
ℹ️ View Unchanged
|
Contributor
|
Size Change: 0 B Total Size: 21.5 kB ℹ️ View Unchanged
|
uyarn
approved these changes
Sep 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

🤔 这个 PR 的性质是?
🔗 相关 Issue
无
💡 需求背景和解决方案
t-popup在 Shadow DOM 下有两处 broken:onDocumentMouseDown用popperEl.contains(ev.target)判断点击是否在弹层内。Shadow DOM 下 document 层的事件target被重定向到 shadow host,contains恒为false,点击弹层内部误关闭。onMouseLeave→getPopperTree用document.querySelectorAll查找子弹层,判断光标是否仍在弹层上。querySelectorAll不穿透 shadow 边界,返回空数组,hover 移向子弹层时父弹层误关闭。解决方案:
event.composedPath().includes(element) || element.contains(ev.target),事件路径可穿透 shadow 边界。getPopperTree增加查询根参数,通过getRootNode()解析弹层所在的Document | ShadowRoot,并同时查询document(覆盖父弹层与子弹层挂载在不同根节点的混合场景,如父弹层在 shadow root、子弹层默认attach: 'body');纯 document 场景行为不变。📝 更新日志
tdesign-vue-next
☑️ 请求合并前的自查清单
测试:
pnpm exec vitest run packages/components/popup/__tests__/popup.test.tsx90 项全部通过(新增 3 个 Shadow DOM 回归用例,含混合根节点场景);Select/Dropdown 共 200 项冒烟通过。