Skip to content

[toast] Prevent dismissed promise toast from reopening on updates - #4040

Merged
atomiks merged 4 commits into
mui:masterfrom
atomiks:codex/f333-toast-promise-dismiss-race
Feb 11, 2026
Merged

atomiks merged 4 commits into
mui:masterfrom
atomiks:codex/f333-toast-promise-dismiss-race

Conversation

@atomiks

@atomiks atomiks commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

Most noticeable with promise toasts: if you dismiss and while exiting it updates, it comes back into (half) view, depending on the swipe amount

@atomiks atomiks added type: bug It doesn't behave as expected. component: toast Changes related to the toast component. labels Feb 11, 2026
@pkg-pr-new

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

commit: 967fa56

@mui-bot

mui-bot commented Feb 11, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+71B(+0.02%) 🔺+18B(+0.01%)

Details of bundle changes


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

@netlify

netlify Bot commented Feb 11, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 967fa56
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/698c4a6512c4a90008704506
😎 Deploy Preview https://deploy-preview-4040--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks
atomiks marked this pull request as ready for review February 11, 2026 00:59
@greptile-apps

greptile-apps Bot commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This PR fixes a race condition where dismissed promise toasts would reopen when they resolved/rejected during their exit animation. The fix adds two defensive guards:

  1. store.ts:190-195 - Prevents any updates to toasts with transitionStatus === 'ending', blocking async promise updates from interfering with dismissal
  2. ToastRoot.tsx:165 - Only resets transitionStatus to undefined when it's 'starting', preserving the 'ending' state during exit animations

The solution correctly handles the async nature of promise toasts where updateToast can be called after a user dismisses the toast but before the promise settles. Both test files include new tests verifying the fix works correctly.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are minimal, well-targeted, and defensive in nature. The fix correctly addresses the race condition by adding guards that prevent state corruption without changing existing behavior. Comprehensive tests validate the fix and the logic aligns with the existing transition status model.
  • No files require special attention

Important Files Changed

Filename Overview
packages/react/src/toast/store.ts Added guard in updateToastInternal to prevent updates when toast is closing (transitionStatus === 'ending'), fixing race condition with promise toasts
packages/react/src/toast/root/ToastRoot.tsx Modified height recalculation to only reset transitionStatus when it's 'starting', preventing reopening of dismissed toasts during updates
packages/react/src/toast/createToastManager.test.tsx Added test to verify dismissed promise toasts don't reopen when resolved, validating the fix for the race condition
packages/react/src/toast/useToastManager.test.tsx Added Toast.Close to CustomList component and test for dismissed promise toast race condition, ensuring comprehensive test coverage

@atomiks
atomiks merged commit b8a75cf into mui:master Feb 11, 2026
7 checks passed
@atomiks
atomiks deleted the codex/f333-toast-promise-dismiss-race branch February 11, 2026 09:32
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.

3 participants