[PR #25] fix: auto-generate unique IDs so multiple toasts display simultaneously #28

Open
opened 2026-03-02 05:16:38 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hiaaryan/sileo/pull/25
Author: @lubauss
Created: 2/21/2026
Status: 🔄 Open

Base: mainHead: fix/unique-toast-ids


📝 Commits (1)

  • 741c3f9 fix: auto-generate unique IDs so multiple toasts display simultaneously

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 src/toast.tsx (+1 -1)

📄 Description

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 no id is provided, it defaults to "sileo-default":

const id = merged.id ?? "sileo-default";

This means every toast without an explicit id shares the same identifier. Calling sileo.success(...) twice in quick succession replaces the first toast instead of showing two separate notifications.

// Only shows ONE toast — the second replaces the first
sileo.success({ title: "Toast 1" });
sileo.success({ title: "Toast 2" });

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:

// Before
const id = merged.id ?? "sileo-default";

// After
const id = merged.id ?? generateId();

generateId() produces IDs like "3-m1abc2d-x7k9f2" (counter + timestamp + random), ensuring uniqueness.

Files Changed

File Changes
src/toast.tsx (line 134) Replace "sileo-default" with generateId()

Backward Compatibility

  • Explicit id usage still works exactly as before (deduplicated)
  • Only affects the default case where no id is provided
  • Users who want the old "replace" behavior can pass a fixed id:
// Still deduplicates when you pass an explicit id
sileo.success({ title: "Toast 1", id: "my-toast" });
sileo.success({ title: "Toast 2", id: "my-toast" }); // Replaces first

Testing

// After fix: shows TWO separate toasts
sileo.success({ title: "Toast 1" });
sileo.success({ title: "Toast 2" });

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hiaaryan/sileo/pull/25 **Author:** [@lubauss](https://github.com/lubauss) **Created:** 2/21/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/unique-toast-ids` --- ### 📝 Commits (1) - [`741c3f9`](https://github.com/hiaaryan/sileo/commit/741c3f905afb3b471f1ca6d02f47c565447882a2) fix: auto-generate unique IDs so multiple toasts display simultaneously ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/toast.tsx` (+1 -1) </details> ### 📄 Description ## 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 no `id` is provided, it defaults to `"sileo-default"`: ```ts const id = merged.id ?? "sileo-default"; ``` This means every toast without an explicit `id` shares the same identifier. Calling `sileo.success(...)` twice in quick succession **replaces** the first toast instead of showing two separate notifications. ```ts // Only shows ONE toast — the second replaces the first sileo.success({ title: "Toast 1" }); sileo.success({ title: "Toast 2" }); ``` 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: ```ts // Before const id = merged.id ?? "sileo-default"; // After const id = merged.id ?? generateId(); ``` `generateId()` produces IDs like `"3-m1abc2d-x7k9f2"` (counter + timestamp + random), ensuring uniqueness. ## Files Changed | File | Changes | |------|---------| | `src/toast.tsx` (line 134) | Replace `"sileo-default"` with `generateId()` | ## Backward Compatibility - Explicit `id` usage still works exactly as before (deduplicated) - Only affects the default case where no `id` is provided - Users who want the old "replace" behavior can pass a fixed `id`: ```ts // Still deduplicates when you pass an explicit id sileo.success({ title: "Toast 1", id: "my-toast" }); sileo.success({ title: "Toast 2", id: "my-toast" }); // Replaces first ``` ## Testing ```ts // After fix: shows TWO separate toasts sileo.success({ title: "Toast 1" }); sileo.success({ title: "Toast 2" }); ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/sileo#28
No description provided.