Skip to content

[dialog] Fix nested-dialog counts and dismissal edge cases#5033

Draft
atomiks wants to merge 1 commit into
mui:masterfrom
atomiks:dialog/nested-dialog-bugs
Draft

[dialog] Fix nested-dialog counts and dismissal edge cases#5033
atomiks wants to merge 1 commit into
mui:masterfrom
atomiks:dialog/nested-dialog-bugs

Conversation

@atomiks

@atomiks atomiks commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Several Dialog/AlertDialog fixes:

  • Nested-dialog counts are now aggregated per child (keyed by a stable id, via Math.max) instead of last-writer-wins, so closing one of two sibling nested dialogs no longer zeroes the parent's count while the other stays open. That fixes the downstream Escape / outside-press "topmost" gating (Escape was closing the parent under a still-open child).
  • Outside-press touch dismissal now counts changedTouches (the touches list is empty on touchend, which made the guard a dead path).
  • First-render initial-open state is assigned to store.state directly instead of via store.update() (which notifies synchronously during render), matching useInitialOpenSync.
  • A reused handle store's openProp is seeded on first render so an initially-open <Dialog.Root handle open> doesn't play an enter transition.
  • Close events report the trigger via the triggerId-prop-aware selector in fully controlled mode.

Adds a nested sibling-close regression test.

@atomiks atomiks added component: alert dialog Changes related to the alert dialog component. type: bug It doesn't behave as expected. component: dialog Changes related to the dialog component. labels Jun 12, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 12, 2026

Copy link
Copy Markdown

commit: 6cbdb10

@code-infra-dashboard

code-infra-dashboard Bot commented Jun 12, 2026

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+390B(+0.08%) 🔺+140B(+0.09%)

Details of bundle changes

Performance

Total duration: 1,150.96 ms ▼-303.28 ms(-20.9%) | Renders: 50 (+0) | Paint: 1,745.44 ms ▼-438.95 ms(-20.1%)

Test Duration Renders
Slider mount (300 instances) 144.17 ms ▼-50.84 ms(-26.1%) 3 (+0)
Checkbox mount (500 instances) 81.14 ms ▼-32.95 ms(-28.9%) 1 (+0)
Select open (500 options) 42.74 ms ▼-19.57 ms(-31.4%) 14 (+0)
Popover mount (300 instances) 61.86 ms ▼-15.66 ms(-20.2%) 1 (+0)
Tooltip mount (300 contained roots) 42.41 ms ▼-14.54 ms(-25.5%) 1 (+0)

…and 1 more (+6 within noise) — details


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Jun 12, 2026

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 6cbdb10
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a2bb3baa3146900087bba1e
😎 Deploy Preview https://deploy-preview-5033--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

- Aggregate nested dialog/drawer counts per child (keyed by a stable id, via
  Math.max) so closing one sibling no longer zeroes the parent while another
  stays open, which also fixes Escape/outside-press topmost gating (B4).
- Accept touchend outside-press by counting changedTouches instead of the now-empty
  touches list (B6).
- Seed store state directly on first render instead of store.update() so detached
  trigger subscribers aren't notified mid-render (B7).
- Seed a reused handle store's openProp on first render so an initially-open
  dialog doesn't play an enter transition (B8).
- Report the trigger on close using the triggerIdProp-aware selector (B9).
- Add a nested sibling-close regression test.
@atomiks atomiks force-pushed the dialog/nested-dialog-bugs branch from 6558238 to 6cbdb10 Compare June 12, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: alert dialog Changes related to the alert dialog component. component: dialog Changes related to the dialog component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant