Skip to content

[toast] Fix re-adding a closing toast#5258

Merged
atomiks merged 5 commits into
mui:masterfrom
atomiks:codex/fix-toast-readd-during-exit
Jul 20, 2026
Merged

[toast] Fix re-adding a closing toast#5258
atomiks merged 5 commits into
mui:masterfrom
atomiks:codex/fix-toast-readd-during-exit

Conversation

@atomiks

@atomiks atomiks commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #5253

Changes

  • Reinitialized retained toast roots when a closing toast is re-added with the same ID.
  • Kept content height recalculation from clearing transition state.
  • Added regression tests for revived and remounted toast roots.

@atomiks atomiks added type: bug It doesn't behave as expected. component: toast Changes related to the toast component. labels Jul 17, 2026 — with ChatGPT Codex Connector
@pkg-pr-new

pkg-pr-new Bot commented Jul 17, 2026

Copy link
Copy Markdown

commit: d13d9ea

@atomiks
atomiks force-pushed the codex/fix-toast-readd-during-exit branch from d747684 to 6d05a1a Compare July 17, 2026 07:58
@netlify

netlify Bot commented Jul 17, 2026

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

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

@code-infra-dashboard

code-infra-dashboard Bot commented Jul 17, 2026

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+196B(+0.04%) 🔺+54B(+0.04%)

Details of bundle changes

Performance

Total duration: 1,398.71 ms +26.65 ms(+1.9%) | Renders: 78 (+0) | Paint: 2,209.31 ms +58.84 ms(+2.7%)

Test Duration Renders
Select mount (200 instances) 177.50 ms 🔺+31.79 ms(+21.8%) 3 (+0)
Combobox type — 500 items, narrows to ~11 (type "Row 25") 44.52 ms 🔺+12.10 ms(+37.3%) 15 (+0)
Combobox open — 500 items 47.53 ms 🔺+9.16 ms(+23.9%) 4 (+0)
Checkbox mount (500 instances) 65.96 ms ▼-28.54 ms(-30.2%) 1 (+0)

11 tests within noise — details

Metric alarms

Test Metric Change
Select mount (200 instances) bench:paint 🔺 +40.70 ms
Combobox type — 500 items, narrows to ~11 (type "Row 25") bench:paint#combobox-open 🔺 +21.02 ms
Combobox type — 500 items, narrows to ~11 (type "Row 25") bench:paint 🔺 +21.02 ms
Combobox open — 500 items bench:paint#combobox-open 🔺 +15.21 ms
Combobox open — 500 items bench:paint 🔺 +15.21 ms

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

@netlify

netlify Bot commented Jul 17, 2026

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit d13d9ea
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a5e295e3624e50008e0c556
😎 Deploy Preview https://deploy-preview-5258--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 marked this pull request as ready for review July 17, 2026 11:21
@atomiks
atomiks requested a review from Copilot July 20, 2026 03:47

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 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 ToastRoot internal 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.

@atomiks
atomiks requested a review from Copilot July 20, 2026 13:40

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

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

Comment thread packages/react/src/toast/root/ToastRoot.tsx Outdated
Comment thread packages/react/src/toast/root/ToastRoot.test.tsx
@atomiks
atomiks merged commit 244aea5 into mui:master Jul 20, 2026
23 checks passed
@atomiks
atomiks deleted the codex/fix-toast-readd-during-exit branch July 20, 2026 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Toast] Re-triggering a toast during exit animation breaks stack indexing, incorrectly applying data-behind

2 participants