Skip to content

[navigation menu] Preserve exit transition when controlled#4855

Merged
atomiks merged 10 commits into
mui:masterfrom
mattrothenberg:mrothenberg/fix-navigation-menu-controlled-close
May 22, 2026
Merged

[navigation menu] Preserve exit transition when controlled#4855
atomiks merged 10 commits into
mui:masterfrom
mattrothenberg:mrothenberg/fix-navigation-menu-controlled-close

Conversation

@mattrothenberg
Copy link
Copy Markdown
Contributor

@mattrothenberg mattrothenberg commented May 19, 2026

Problem

When NavigationMenu is controlled, consumers can close it by updating value to null directly. That prop-driven close does not go through the same internal setValue(null, eventDetails) path used by interactions like hover-out, so the popup dimensions may be measured after active content has already started unmounting. In that case the popup can collapse immediately, making the data-ending-style exit transition appear to be skipped.

Reproduction

Working

https://stackblitz.com/edit/vitejs-vite-czwevbev?file=src%2FApp.tsx

Solution

  • snapshot the current popup and positioner dimensions when an open controlled NavigationMenu commits to closing
  • reuse the existing fixed-size CSS variables used by the internal interaction close path
  • keep the change internal to NavigationMenu without adding a new public API
  • add a regression test for externally setting the controlled value to null while the popup exits
  • add a public controlled-close docs demo for visual verification

Testing

  • pnpm vitest run packages/react/src/navigation-menu/root/NavigationMenuRoot.test.tsx --project @base-ui/react
  • pnpm --filter docs typescript
  • Manually verified the docs demo at /react/components/navigation-menu: unchecking "Menu open" applies data-ending-style with frozen popup dimensions

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 19, 2026

commit: 3e34463

@code-infra-dashboard
Copy link
Copy Markdown

code-infra-dashboard Bot commented May 19, 2026

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+29B(+0.01%) 🔺+57B(+0.04%)

Details of bundle changes

Performance

Total duration: 1,296.03 ms +114.84 ms(+9.7%) | Renders: 50 (+0) | Paint: 1,962.57 ms +130.00 ms(+7.1%)

Test Duration Renders
Menu mount (300 instances) 152.01 ms 🔺+28.76 ms(+23.3%) 2 (+0)
Mixed surface mount (app-like density) 93.46 ms 🔺+20.35 ms(+27.8%) 5 (+0)
Scroll Area mount (300 instances) 98.54 ms 🔺+17.72 ms(+21.9%) 3 (+0)
Select open (500 options) 51.78 ms 🔺+12.78 ms(+32.8%) 14 (+0)

8 tests within noise — details


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

@netlify
Copy link
Copy Markdown

netlify Bot commented May 19, 2026

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 3e34463
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a100e0efe45d00008b84c62
😎 Deploy Preview https://deploy-preview-4855--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 type: bug It doesn't behave as expected. component: navigation menu Changes related to the navigation menu component. labels May 19, 2026
@atomiks atomiks force-pushed the mrothenberg/fix-navigation-menu-controlled-close branch 3 times, most recently from aeeeb71 to e8efc77 Compare May 19, 2026 12:45
@oliviertassinari oliviertassinari changed the title [navigation-menu] Preserve exit transition when controlled [navigation menu] Preserve exit transition when controlled May 19, 2026
@atomiks atomiks force-pushed the mrothenberg/fix-navigation-menu-controlled-close branch from 2f7c24b to f7055d1 Compare May 22, 2026 06:29
@atomiks atomiks merged commit 3a6a785 into mui:master May 22, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants