Skip to content

[popups] Don't let a late trigger claim a programmatically-opened popup#5031

Draft
atomiks wants to merge 1 commit into
mui:masterfrom
atomiks:popups/trigger-claim-fix
Draft

[popups] Don't let a late trigger claim a programmatically-opened popup#5031
atomiks wants to merge 1 commit into
mui:masterfrom
atomiks:popups/trigger-claim-fix

Conversation

@atomiks

@atomiks atomiks commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

A trigger that mounts while a popup is already open via a handle's openWithPayload() / open(null) would claim ownership and overwrite the programmatically-set payload — contradicting openWithPayload's contract ("does not associate the dialog with any trigger").

Track openedWithoutTrigger in the popup store and skip the registration-time claim, the implicit single-trigger claim, and the single-trigger aria-controls association for such opens. The flag is reset on close so a later non-imperative open (controlled open / defaultOpen) isn't affected. DialogHandle.open(id) records trigger intent so opening before the trigger mounts still associates correctly.

This is shared popup infrastructure, so it also covers Popover/Menu detached triggers. Adds regression tests for payload preservation and the absent ARIA association.

A trigger that mounts while a popup is already open (via a handle's
openWithPayload/open(null)) would claim ownership and overwrite the
programmatic payload. Track openedWithoutTrigger in the popup store and skip
the implicit, registration-time, and single-trigger ARIA (aria-controls) claim
paths for such opens; reset the flag on close so a later non-imperative open
(controlled/defaultOpen) isn't affected. DialogHandle.open records trigger
intent so handle.open(id) before mount still associates. Adds regression tests
for payload preservation and the absent ARIA association. (B5)
@atomiks atomiks added type: bug It doesn't behave as expected. component: dialog Changes related to the dialog component. component: popover Changes related to the popover component. labels Jun 12, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 12, 2026

Copy link
Copy Markdown

commit: 7d62b35

@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 🔺+280B(+0.06%) 🔺+75B(+0.05%)

Details of bundle changes

Performance

Total duration: 1,157.49 ms ▼-296.75 ms(-20.4%) | Renders: 50 (+0) | Paint: 1,735.65 ms ▼-448.73 ms(-20.5%)

Test Duration Renders
Tabs mount (200 instances) 211.34 ms ▼-60.11 ms(-22.1%) 4 (+0)
Checkbox mount (500 instances) 61.48 ms ▼-52.61 ms(-46.1%) 1 (+0)
Select mount (200 instances) 139.36 ms ▼-35.16 ms(-20.1%) 3 (+0)
Popover mount (300 instances) 61.27 ms ▼-16.25 ms(-21.0%) 1 (+0)
Tooltip mount (300 contained roots) 43.94 ms ▼-13.02 ms(-22.9%) 1 (+0)

7 tests 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 7d62b35
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a2bad0ce2b5230009fe2cdc
😎 Deploy Preview https://deploy-preview-5031--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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant