Skip to content

[popups] Consider the controlled open prop for open state detection - #4712

Merged
michaldudak merged 4 commits into
mui:masterfrom
michaldudak:menu-popup-open
May 1, 2026
Merged

michaldudak merged 4 commits into
mui:masterfrom
michaldudak:menu-popup-open

Conversation

@michaldudak

@michaldudak michaldudak commented Apr 30, 2026 •

Copy link
Copy Markdown
Member

Fixes the controlled popup trigger state after a close request is vetoed.

Updated shared popup trigger state to derive isOpenedByTrigger from the effective open state, openProp ?? open, instead of raw internal open.

Fixes #4709

@michaldudak michaldudak added component: tooltip Changes related to the tooltip component. component: dialog Changes related to the dialog component. component: popover Changes related to the popover component. component: menu Changes related to the menu component. component: preview card Changes related to the preview card component. type: bug It doesn't behave as expected. labels Apr 30, 2026
@pkg-pr-new

pkg-pr-new Bot commented Apr 30, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@4712
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@4712
    

commit: 3eb978b

@code-infra-dashboard

code-infra-dashboard Bot commented Apr 30, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+45B(+0.01%) 🔺+31B(+0.02%)

Details of bundle changes

Performance

Total duration: 1,581.03 ms 🔺+285.76 ms(+22.1%) | Renders: 53 (+0) | Paint: 2,427.54 ms 🔺+400.97 ms(+19.8%)

Test Duration Renders
Tabs mount (200 instances) 289.68 ms 🔺+80.31 ms(+38.4%) 4 (+0)
Tooltip mount (300 contained roots) 91.67 ms 🔺+38.30 ms(+71.8%) 2 (+0)
Select mount (200 instances) 184.14 ms 🔺+36.24 ms(+24.5%) 3 (+0)
Menu mount (300 instances) 164.40 ms 🔺+35.03 ms(+27.1%) 2 (+0)
Popover mount (300 instances) 119.74 ms 🔺+33.16 ms(+38.3%) 2 (+0)

…and 7 more — details


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

@netlify

netlify Bot commented Apr 30, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 3eb978b
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69f457bfe496570008d479cb
😎 Deploy Preview https://deploy-preview-4712--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.

@michaldudak
michaldudak marked this pull request as ready for review April 30, 2026 08:09
@michaldudak

Copy link
Copy Markdown
Member Author

Codex Review (GPT-5.5)

This follow-up review covers the full PR branch against freshly fetched upstream/master. The implementation now addresses the prior public-handle mismatch and I did not find additional blocking or non-blocking issues.

1. Remaining Bugs / Issues (None)

No remaining actionable issues found.

Previous Review Issues Status

The prior issue with public handles reporting stale raw store.state.open after a controlled close veto is resolved. DialogHandle, MenuHandle, PopoverHandle, PreviewCardHandle, and TooltipHandle now read the effective popup state via store.select('open'), matching the selector-backed state used by rendered popup parts and triggers.

Root Cause & Patch Assessment

The core fix is consistent: isOpenedByTrigger now uses the same effective open calculation as the public open selector, so controlled openProp takes precedence over attempted internal state changes. The extracted getOpen helper keeps the selector logic shared and avoids a second raw openProp ?? open implementation.

The handle updates are also aligned with that model. Since the affected stores are constructed with popup selectors, this.store.select('open') is valid for both internally owned and handle-owned stores.

Test Coverage Assessment

The added tests cover the low-level selector cases and the controlled close-veto flow through Menu and AlertDialog, including handle.isOpen. I also validated the broader handle/detached-trigger surface.

Commands run:

pnpm typescript
pnpm test:jsdom MenuTrigger AlertDialogRoot popups/store --no-watch
pnpm test:jsdom detached-triggers --no-watch
pnpm test:chromium detached-triggers --no-watch
git diff --check upstream/master...origin/menu-popup-open

All passed.

Recommendation

Approve ✅

The implementation is small, consistent with the existing popup store architecture, and the previously identified public API mismatch is fixed with targeted coverage. I don’t see further issues that should block this PR.

@mj12albert mj12albert left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

@michaldudak
michaldudak merged commit 5f97f0a into mui:master May 1, 2026
6 checks passed
@michaldudak
michaldudak deleted the menu-popup-open branch May 1, 2026 07:42
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: menu Changes related to the menu component. component: popover Changes related to the popover component. component: preview card Changes related to the preview card component. component: tooltip Changes related to the tooltip component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[menu] Keep [data-popup-open] on trigger when Menu.Popup is open

2 participants