Skip to content

[menu] Fix exit animation not running on uncheck of item - #5252

Merged
sai6855 merged 4 commits into
mui:masterfrom
sai6855:menu-exit-animation
Jul 16, 2026
Merged

sai6855 merged 4 commits into
mui:masterfrom
sai6855:menu-exit-animation

Conversation

@sai6855

@sai6855 sai6855 commented Jul 16, 2026 •

Copy link
Copy Markdown
Member

Menu.CheckboxItemIndicator and Menu.RadioItemIndicator gated rendering on the raw item.checked instead of mounted from useTransitionStatus, so a non-keepMounted indicator unmounted instantly on uncheck and never played its [data-ending-style] exit animation (unlike Checkbox.Indicator/Radio.Indicator).

...elementProps,
},
enabled: keepMounted || item.checked,
enabled: keepMounted || mounted,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Changing gate from item.checked to mounted allowed element to be present in DOM and run exit animations.

@pkg-pr-new

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

commit: e583500

@code-infra-dashboard

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

Copy link
Copy Markdown

Bundle size

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

Details of bundle changes

Performance

Total duration: 1,512.70 ms +80.36 ms(+5.6%) | Renders: 78 (+0) | Paint: 2,350.82 ms +128.13 ms(+5.8%)

Test Duration Renders
Checkbox mount (500 instances) 99.72 ms 🔺+22.69 ms(+29.5%) 1 (+0)
Combobox type — 500 items, all stay mounted (type "Row ") 41.42 ms 🔺+7.95 ms(+23.7%) 11 (+0)

12 tests within noise — details

Metric alarms

Test Metric Change
Checkbox mount (500 instances) bench:paint 🔺 +27.23 ms

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

@netlify

netlify Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Built without sensitive environment variables

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Menu checkbox/radio item indicators unmounting too early when an item becomes unchecked, which prevented the indicator’s exit animation from running. It aligns Menu indicator mounting behavior with the existing pattern used by other indicators (e.g., CheckboxIndicator) by basing rendering on useTransitionStatus().mounted rather than the raw checked state.

Changes:

  • Use useTransitionStatus(item.checked).mounted to keep MenuCheckboxItemIndicator and MenuRadioItemIndicator mounted through the “ending” transition.
  • Add Playwright-only tests verifying the indicator remains mounted long enough to apply data-ending-style and then unmounts after the exit animation.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/react/src/menu/radio-item-indicator/MenuRadioItemIndicator.tsx Switches rendering enablement from item.checked to mounted to allow exit animations to run before unmount.
packages/react/src/menu/radio-item-indicator/MenuRadioItemIndicator.test.tsx Adds a browser-only regression test ensuring unchecked indicators stay mounted for exit animation without keepMounted.
packages/react/src/menu/checkbox-item-indicator/MenuCheckboxItemIndicator.tsx Same mounting/enablement change as radio indicator, applied to checkbox indicator.
packages/react/src/menu/checkbox-item-indicator/MenuCheckboxItemIndicator.test.tsx Adds a browser-only regression test ensuring unchecked indicators stay mounted for exit animation without keepMounted.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sai6855 sai6855 added component: menu Changes related to the menu component. type: bug It doesn't behave as expected. labels Jul 16, 2026
@sai6855
sai6855 marked this pull request as ready for review July 16, 2026 06:31
Comment on lines +132 to +137
it('keeps the indicator mounted to play its exit animation when unchecked without keepMounted', async ({
skip,
}) => {
if (isJSDOM) {
skip();
}

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.

it.skipIf(isJSDOM) should work. (The other tests for this are stale I believe)

@sai6855
sai6855 merged commit 6b3bed6 into mui:master Jul 16, 2026
6 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.

3 participants