fix: auto-generate unique IDs so multiple toasts display simultaneously#25
Open
lubauss wants to merge 1 commit intohiaaryan:mainfrom
Open
fix: auto-generate unique IDs so multiple toasts display simultaneously#25lubauss wants to merge 1 commit intohiaaryan:mainfrom
lubauss wants to merge 1 commit intohiaaryan:mainfrom
Conversation
The default toast ID was hardcoded to "sileo-default", meaning every toast without an explicit id shared the same identifier. Calling sileo.success() twice would replace the first toast instead of showing two separate notifications. Changed the fallback to use the existing generateId() helper, which produces unique IDs (counter + timestamp + random). Users who want the old "replace" behavior can still pass an explicit id.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Change the default toast ID from the hardcoded
"sileo-default"to an auto-generated unique ID, so multiple toasts can display simultaneously.Problem
In
createToast(), when noidis provided, it defaults to"sileo-default":This means every toast without an explicit
idshares the same identifier. Callingsileo.success(...)twice in quick succession replaces the first toast instead of showing two separate notifications.This is unexpected — most toast libraries (Sonner, react-hot-toast, etc.) show each call as a separate notification.
Solution
Use the existing
generateId()helper (already defined in the file) as the default:generateId()produces IDs like"3-m1abc2d-x7k9f2"(counter + timestamp + random), ensuring uniqueness.Files Changed
src/toast.tsx(line 134)"sileo-default"withgenerateId()Backward Compatibility
idusage still works exactly as before (deduplicated)idis providedid:Testing