Repository navigation
[dialog] Keep parent open when closing a nested dialog in a closed shadow root - #5780
Merged
atomiks merged 3 commits intoSep 24, 2026
Merged
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,045.38 ms -111.75 ms(-9.7%) | Renders: 76 (+0) | Paint: 1,706.31 ms -206.55 ms(-10.8%)
10 tests within noise — details Metric alarms
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
atomiks
marked this pull request as ready for review
September 23, 2026 09:47
atomiks
requested review from
colmtuite,
flaviendelangle,
jjenzz and
michaldudak
as code owners
September 23, 2026 09:47
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.
Fixes #5650
When a dialog is portaled into a closed shadow root, clicking inside a nested dialog (for example its
Dialog.Close) also dismissed the parent dialog with reasonoutside-press.From the document, a closed shadow root hides the real target:
composedPath()stops at the shadow host, so the parent'suseDismisscan't tell that the press landed inside its popup tree. The only signal left is the React-tree marker (insideReactTree), which the popup's capture handlers set before the press reaches the host. But with real input, React flushes the nested dialog's close in a microtask before the host listener runs. That flips the parent'sescapeKey/topmost state and re-runs its dismiss effect, and the effect's cleanup cleared the marker. The press was then treated as outside.This PR stops clearing the marker in that effect's cleanup and clears it on unmount instead. The existing 0 ms timeout and the reset on reopen still clear it as before. Open shadow roots and light DOM aren't affected, since there the target check runs before React handles the press.
Nested
Dialog(modal and non-modal) andAlertDialoginside aDialogwere affected whenever either popup was portaled into the closed shadow root. Popover, Menu, and Select inside a dialog, and nested popovers, already worked because closing them doesn't change the parent's dismiss effect.The tests cover each nested kind across the possible portal setups (outer and nested in the shadow root, the body, or the inherited default). Synthetic clicks and
act()both defer React's flush until after the host listener, which hides the bug, so the test click flushes React from a shadow root listener, which is what the browser's microtask checkpoint does for trusted input.