[toast] Fix re-adding a closing toast#5258
Conversation
commit: |
d747684 to
6d05a1a
Compare
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Bundle size
PerformanceTotal duration: 1,398.71 ms +26.65 ms(+1.9%) | Renders: 78 (+0) | Paint: 2,209.31 ms +58.84 ms(+2.7%)
11 tests within noise — details Metric alarms
Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
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 a Toast Manager edge case where re-triggering a toast while it is exiting (same id) could leave the UI in a broken state (incorrect stacking/data-behind behavior and missing content). It does so by ensuring toast roots are properly (re)initialized when a toast is revived, while preventing height recalculation updates from unintentionally clearing transition state.
Changes:
- Reinitialize
ToastRootinternal registration (ref/height/transition state) on mount and when a retained root’s toast is revived (transitionStatus: 'starting'). - Stop height recalculation updates from writing
transitionStatus: undefined, avoiding unintended transition-state resets during content/height observer updates. - Add regression tests for reviving a closing toast and for correct re-registration after a toast root remounts (browser-only).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/react/src/toast/store.test.ts | Updates regression coverage to reflect the new “height-only” internal updates. |
| packages/react/src/toast/root/ToastRoot.tsx | Adds (re)initialization layout effect and refactors height measurement to avoid clearing transition state during height recalculation. |
| packages/react/src/toast/root/ToastRoot.test.tsx | Adds browser-only regression tests covering revived-toasts and remounted-root registration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes #5253
Changes