Repository navigation
fix(overlay): pick components inside ShadowDom components - #285
Conversation
The component picker listens on the document, where an event from inside a shadow root is retargeted to its host. hostOf walked up from that host, so hovering or clicking a component inside a ViewEncapsulation.ShadowDom component always picked the outer host. It now starts from the first entry of the event's composed path, the element really under the pointer.
🚀 Deploying Preview to Cloudflare 🚀Preview Deployments by commit
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to This change lets the component picker select components inside open shadow roots instead of their outer host. No merge-blocking risk is evident, and the author reports the relevant checks passed. Pre-merge checks |
|
What and why
The Components tab and the component tree do show components inside open shadow roots (
ViewEncapsulation.ShadowDom), but the on-page picker couldn't select them. Its listeners are ondocumentin the capture phase, and there the browser retargets an event from inside a shadow root to the shadow host.hostOf(event.target)then walked up from the host, so hover outlines and clicks always landed on the outer ShadowDom component.hostOfnow starts fromevent.composedPath()[0], the element really under the pointer. The check that ignores clicks on the devtools popup still usesevent.target, which is what that check needs because the popup is itself a shadow host.How it was verified
New test in
component-pick.test.tswith a ShadowDom shell component containing a child component. Onmainclicking the child selectsapp-shell. With the fix it selectsapp-trip-card. All package tests pass.pnpm commit:check(commit messages follow the guidelines)pnpm format:checkpnpm typecheck(includes thengctemplate checks)pnpm test:devtools(all passing)pnpm skills:check(when.claude/changed): not changedno-docs)pnpm extension:buildandextension/uicommitted (whenapp/changed): not changedSummary by CodeRabbit