Skip to content

[menu] Fix submenu spuriously closing as sibling before node ids are registered - #5344

Closed
atomiks wants to merge 1 commit into
mui:masterfrom
atomiks:claude/reverent-shamir-e5f88f
Closed

atomiks wants to merge 1 commit into
mui:masterfrom
atomiks:claude/reverent-shamir-e5f88f

Conversation

@atomiks

@atomiks atomiks commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

MenuPositioner's menuopenchange sibling check compares details.parentNodeId with the menu's own floatingParentNodeId using strict equality. Both ids can still be null before floating node registration — a root menu's node id only reaches the store while it is open — so the comparison matches spuriously. Concretely, a defaultOpen kept-mounted submenu under a closed kept-mounted parent closes itself with reason sibling-open the moment its parent opens, because the parent's open emit fires as { parentNodeId: null } before ids are registered.

The fix guards the comparison so a menu is only treated as a sibling when details.parentNodeId is non-null (strict equality then implies the store side is non-null too). There is no legitimate null–null sibling case: standalone roots each create their own floating tree, and registered submenus always have a non-null parent id.

Adds a regression test that asserts the submenu receives no sibling-open close when its parent opens; it asserts on the close reason rather than open state, since focus-out closes in jsdom could otherwise mask the result. Verified failing before the fix.

@atomiks atomiks added component: menu Changes related to the menu component. type: bug It doesn't behave as expected. labels Jul 27, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 27, 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@5344
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@5344
    

commit: 80a3db3

@code-infra-dashboard

code-infra-dashboard Bot commented Jul 27, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+22B(0.00%) 🔺+5B(0.00%)

Details of bundle changes

Performance

Total duration: 1,273.97 ms +12.89 ms(+1.0%) | Renders: 78 (+0) | Paint: 1,974.63 ms -15.62 ms(-0.8%)

Test Duration Renders
Menu open (500 items) 111.80 ms 🔺+41.08 ms(+58.1%) 12 (+0)
Scroll Area mount (300 instances) 115.84 ms 🔺+35.08 ms(+43.4%) 3 (+0)
Select mount (200 instances) 144.76 ms ▼-41.99 ms(-22.5%) 3 (+0)
Slider mount (300 instances) 96.87 ms ▼-28.66 ms(-22.8%) 2 (+0)
Mixed surface mount (app-like density) 83.62 ms +12.46 ms(+17.5%) 5 (+0)

10 tests within noise — details

Metric alarms

Test Metric Change
Menu open (500 items) bench:paint 🔺 +64.52 ms
Menu open (500 items) bench:paint#menu-open 🔺 +64.52 ms
Scroll Area mount (300 instances) bench:paint 🔺 +30.72 ms
Mixed surface mount (app-like density) bench:paint 🔺 +26.73 ms

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

@netlify

netlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 80a3db3
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a66e002aae50b000983daf3
😎 Deploy Preview https://deploy-preview-5344--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.

@atomiks atomiks closed this Aug 6, 2026
@atomiks
atomiks deleted the claude/reverent-shamir-e5f88f branch August 6, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant