Skip to content

[menu] Release the submenu parent store subscription on unmount - #5833

Merged
atomiks merged 2 commits into
mui:masterfrom
santiago-ramos-02:fix/menu-submenu-parent-subscription
Oct 1, 2026
Merged

atomiks merged 2 commits into
mui:masterfrom
santiago-ramos-02:fix/menu-submenu-parent-subscription

Conversation

@santiago-ramos-02

@santiago-ramos-02 santiago-ramos-02 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5832.

A submenu's MenuStore subscribed to its parent store during construction, but the parent subscription cleanup was overwritten by the cleanup for observing parent. Unmounting a submenu therefore retained its store through the parent's listener.

MenuRoot now subscribes from a layout effect and returns the parent-store cleanup directly. The submenu's parent menu store is fixed for its lifetime, so this subscription does not need a second observer or cleanup slot. StrictMode effect replay and Activity hide/show use the same subscribe/cleanup pair. The constructor still shares allowMouseUpTriggerRef synchronously through its existing local-state observer.

Regression tests cover unmount cleanup, StrictMode cleanup, and inherited-state notifications using Vitest matchers. Local validation passed 614 menu/context-menu/menubar tests in jsdom, 189 MenuRoot tests in Chromium, package typechecking, ESLint, and formatting. Temporary diagnostics also verified Activity hide/show and propagation of all three inherited fields with the simplified implementation.

@pkg-pr-new

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

commit: cb896ac

@code-infra-dashboard

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

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react ▼-56B(-0.01%) 🔺+7B(0.00%)

Details of bundle changes

Performance

Total duration: 556.50 ms +4.03 ms(+0.7%) | Renders: 76 (+0) | Paint: 1,016.76 ms +4.41 ms(+0.4%)

Test Duration Renders
Tabs mount (200 instances) 98.12 ms 🔺+21.31 ms(+27.7%) 3 (+0)
Popover mount (300 instances) 20.32 ms 🔺+5.96 ms(+41.5%) 1 (+0)
Mixed surface mount (app-like density) 39.96 ms ▼-13.93 ms(-25.8%) 5 (+0)
Tooltip mount (300 contained roots) 19.01 ms ▼-5.87 ms(-23.6%) 1 (+0)
Combobox type — 500 items, all stay mounted (type "Row ") 13.87 ms ▼-4.17 ms(-23.1%) 11 (+0)

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

Metric alarms

Test Metric Change
Tabs mount (200 instances) bench:paint 🔺 +29.24 ms
Popover mount (300 instances) bench:paint 🔺 +9.61 ms

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

@netlify

netlify Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit cb896ac
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6abdd71d74c3340007811e2b
😎 Deploy Preview https://deploy-preview-5833--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 added component: menu Changes related to the menu component. type: bug It doesn't behave as expected. labels Oct 1, 2026

@atomiks atomiks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix

@atomiks
atomiks merged commit d01a175 into mui:master Oct 1, 2026
25 of 26 checks passed
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.

[menu] Submenu store never releases its parent store subscription

2 participants