Skip to content

[toast] Add upsert support to add method#4440

Open
atomiks wants to merge 4 commits intomui:masterfrom
atomiks:codex/toast-add-upsert
Open

[toast] Add upsert support to add method#4440
atomiks wants to merge 4 commits intomui:masterfrom
atomiks:codex/toast-add-upsert

Conversation

@atomiks
Copy link
Contributor

@atomiks atomiks commented Mar 25, 2026

Closes #4228

https://deploy-preview-4440--base-ui.netlify.app/react/components/toast#deduplicated-toast

This adds built-in upsert behavior to toastManager.add() when callers pass an id, so repeated adds update the existing toast instead of creating a duplicate. Matched toasts keep their identity, refresh their auto-dismiss timer, and a toast that is already ending is replaced with a fresh one instead of being revived mid-dismissal.

It also adds updateKey to toast objects so custom renderers can replay styles when a toast is updated or upserted. The docs now include a deduplicated toast demo that uses updateKey to pulse the existing toast without remounting it.

Changes

  • Treat add({ id }) as an upsert in the toast store and increment updateKey on updates and upserts.
  • Add regression coverage for manager and hook flows, including timer refresh, re-adding while a toast is closing, and updateKey changes on add() and update().
  • Document the id upsert behavior and add a deduplicated toast demo that replays a pulse via updateKey.

@atomiks atomiks added type: new feature Expand the scope of the product to solve a new problem. component: toast Changes related to the toast component. labels Mar 25, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 25, 2026

commit: 1440cbc

@mui-bot
Copy link

mui-bot commented Mar 25, 2026

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+294B(+0.06%) 🔺+107B(+0.07%)

Details of bundle changes


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

@netlify
Copy link

netlify bot commented Mar 25, 2026

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 1440cbc
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69c492468d044a0009edee6e
😎 Deploy Preview https://deploy-preview-4440--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 force-pushed the codex/toast-add-upsert branch from 945e9b7 to cabaa67 Compare March 26, 2026 00:50
@atomiks atomiks marked this pull request as ready for review March 26, 2026 02:16
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: new feature Expand the scope of the product to solve a new problem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[toast] Built-in support for deduplication?

2 participants