Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQUEST] Toast Component: Need indefinite duration option for async operations #254

Open
JuanSpada opened this issue Oct 17, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@JuanSpada
Copy link

Toast Component: Need indefinite duration option for async operations

  • New feature to an existing component

The Toast component from @nimbus-ds/toast currently requires a fixed duration value in milliseconds. This forces developers to guess or set arbitrarily long durations for operations with unknown completion times (like file uploads or API calls).

Example of current implementation:
addToast({ type: "info", text: "Uploading files...", duration: 3000, // Forces us to set a fixed duration });

Expected Behavior
The Toast component should:

Support an indefinite duration option (e.g., duration: null or duration: "infinite")
Provide a method to manually dismiss toasts
Allow updating toast content during long-running operations

Desired API could look like:
const toastId = addToast({ type: "info", text: "Uploading files...", duration: null }); removeToast(toastId);

Use Cases

File uploads with variable duration
API calls with unknown response times
Long-running background operations
Multi-step processes where progress needs to be shown

Why This Matters
Without this feature, developers are forced to:

Set arbitrarily long durations that might be too short or unnecessarily long
Create custom notification systems for long operations
Risk poor UX where loading indicators disappear before operations complete

Suggested Implementation
Add support for:

null or infinite duration value
removeToast(id) method for manual control
Optional update(id, newConfig) method for updating existing toasts

This would align with common patterns seen in other popular toast libraries like react-toastify and react-hot-toast.
Additional Context
This issue was discovered while implementing a multi-file upload feature where the upload duration varies based on file size and quantity. The current implementation forces us to either:

Set a very long duration (potentially showing stale toasts)
Set a short duration (risking the toast disappearing before completion)
Create a custom notification system (defeating the purpose of using a shared component library)

@JuanSpada JuanSpada added the enhancement New feature or request label Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant