You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This fixes outside press dismissal for popups rendered inside a shared ShadowRoot.
The old logic in useDismiss collected data-base-ui-inert markers from the owner document, and the previous shadow DOM follow-up also appended markers from the target's shadow root. That left the injected-element guard comparing a mixed set of markers from different roots.
For clicks on ordinary sibling elements inside the same ShadowRoot, the target's ancestor chain did not contain the document-level markers, so the click could still be treated as a third-party injected element and ignored. The new logic scopes the marker lookup to the event target's actual root, so same-shadow-root outside clicks are compared against the correct marker set and dismiss normally.
Changes
Scope the inert marker lookup in useDismiss to the event target's actual root instead of mixing document-level and shadow-root markers.
Add a regression test that mounts the app inside a ShadowRoot, portals the dialog into that root, and verifies clicking a sibling element dismisses it.
This change fixes outside press dismissal for popups that are mounted and portaled within the same shadow root. It narrows the inert-marker lookup to the event target's actual root and now covers the shadow-root behavior at the hook level plus dialog and popover integration points.
Findings (None)
No blocking issues found in this patch.
Confidence: 4/5
High confidence based on a full pass over the branch diff, the shared useDismiss code path, and focused regression coverage for same-root clicks, outside-the-root clicks, modal dialog behavior, and non-modal popover behavior.
Notes
Reviewed the branch against master, including correctness, accessibility, API/state, maintainability, performance risk, and test coverage.
Verified with focused useDismiss, DialogRoot, and PopoverRoot runs in JSDOM and Chromium.
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
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.
Fixes #4332
Summary
This fixes outside press dismissal for popups rendered inside a shared
ShadowRoot.The old logic in
useDismisscollecteddata-base-ui-inertmarkers from the owner document, and the previous shadow DOM follow-up also appended markers from the target's shadow root. That left the injected-element guard comparing a mixed set of markers from different roots.For clicks on ordinary sibling elements inside the same
ShadowRoot, the target's ancestor chain did not contain the document-level markers, so the click could still be treated as a third-party injected element and ignored. The new logic scopes the marker lookup to the event target's actual root, so same-shadow-root outside clicks are compared against the correct marker set and dismiss normally.Changes
useDismissto the event target's actual root instead of mixing document-level and shadow-root markers.ShadowRoot, portals the dialog into that root, and verifies clicking a sibling element dismisses it.