Skip to content

[navigation menu] Preserve exit transition when controlled#4855

Open
mattrothenberg wants to merge 4 commits into
mui:masterfrom
mattrothenberg:mrothenberg/fix-navigation-menu-controlled-close
Open

[navigation menu] Preserve exit transition when controlled#4855
mattrothenberg wants to merge 4 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: 2f7c24b

@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 🔺+174B(+0.04%) 🔺+55B(+0.04%)

Details of bundle changes

Performance

Total duration: 1,317.26 ms 🔺+243.57 ms(+22.7%) | Renders: 50 (+0) | Paint: 1,994.30 ms 🔺+339.48 ms(+20.5%)

Test Duration Renders
Checkbox mount (500 instances) 97.84 ms 🔺+38.06 ms(+63.7%) 1 (+0)
Menu mount (300 instances) 151.25 ms 🔺+34.58 ms(+29.6%) 2 (+0)
Select mount (200 instances) 169.10 ms 🔺+33.48 ms(+24.7%) 3 (+0)
Slider mount (300 instances) 177.23 ms 🔺+30.16 ms(+20.5%) 3 (+0)
Mixed surface mount (app-like density) 90.37 ms 🔺+23.65 ms(+35.4%) 5 (+0)

…and 3 more (+4 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 2f7c24b
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a0c650d3b3ac200084d43e5
😎 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 2 times, most recently from 275b900 to aeeeb71 Compare May 19, 2026 12:42
@atomiks atomiks force-pushed the mrothenberg/fix-navigation-menu-controlled-close branch 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
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