Repository navigation
[menu] Fix exit animation not running on uncheck of item - #5252
Conversation
| ...elementProps, | ||
| }, | ||
| enabled: keepMounted || item.checked, | ||
| enabled: keepMounted || mounted, |
There was a problem hiding this comment.
Changing gate from item.checked to mounted allowed element to be present in DOM and run exit animations.
commit: |
Bundle size
PerformanceTotal duration: 1,512.70 ms +80.36 ms(+5.6%) | Renders: 78 (+0) | Paint: 2,350.82 ms +128.13 ms(+5.8%)
12 tests within noise — details Metric alarms
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
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).mountedto keepMenuCheckboxItemIndicatorandMenuRadioItemIndicatormounted through the “ending” transition. - Add Playwright-only tests verifying the indicator remains mounted long enough to apply
data-ending-styleand 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.
| it('keeps the indicator mounted to play its exit animation when unchecked without keepMounted', async ({ | ||
| skip, | ||
| }) => { | ||
| if (isJSDOM) { | ||
| skip(); | ||
| } |
There was a problem hiding this comment.
it.skipIf(isJSDOM) should work. (The other tests for this are stale I believe)
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).