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

dismiss() default behaviour when no arguments are passed #1107

Open
somkamarius opened this issue May 3, 2024 · 0 comments
Open

dismiss() default behaviour when no arguments are passed #1107

somkamarius opened this issue May 3, 2024 · 0 comments

Comments

@somkamarius
Copy link

Do you want to request a feature or report a bug?

Feature. Nothing critical, just an idea for an api change. Maybe you'll have some feedback on it too.

What is the current behaviour?

toast.dismiss() currently, when no parameters are passed, dismisses all the active toasts.

However, when some more complicated side effects happen, it's possible to accidentally pass a variable with toastId value that is yet undefined (since it could be stored in useRef value, and perhaps with some setTimeout() usage, or some more complicated usages, toast id is not yet saved in the value). After passing undefined value, all toasts will be closed and that could cause some odd behaviours
What is the expected behavior?
My suggestion for better UX is perhaps change the api, so that toast.dismiss() always requires a toastId? And then either it could be possible to pass the option flag, so that the decision to dismiss all the toasts is explicit, and not just an accident with and undefined value. Or perhaps you could even introduce .dismissAll() as a separate thing.

Just an idea. Perhaps this could save some confusion on debugging for other consumers. Feedback is welcome. Thanks for maintaining this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant