Open nehmykola opened 3 weeks ago
Thanks for the issue, can you provide a little more information? Are you using the hooks? or are you using ReactSpectrum? It sounds like you're using the hooks. A codesandbox or stackblitz would also be helpful to see what you're trying to accomplish.
I can’t pass a custom key or ID to prevent duplication
Preventing duplication seems like something that should be handled at the application layer.
or update existing toasts.
I think Toasts are mostly meant to be immutable. If the content on one becomes stale, you can programmatically remove it and create a new one with the latest information.
Additionally, I need to be able to trigger the same notification from different places in the application.
I think this is something that can be handled at the application level. If two different areas of your app can create toasts for a similar incident, they should share state on whether one has already been created.
Okay, I think I could implement all of the above at the application level. Changing the toast content by closing and opening sounds pretty weird, but maybe it makes sense.
The issue is more that I think screen reader or visual user might not notice a change to an existing toast, so I'm not convinced it's a good idea to support updating the content.
Good point! Thanks for your help ❤️
Provide a general summary of the feature here
I’m using toast creation tools, but I’m facing an issue where I can’t pass a custom key or ID to prevent duplication or update existing toasts.
This functionality is crucial in scenarios where the notification represents task progress and needs to update based on the task status. Additionally, I need to be able to trigger the same notification from different places in the application. To avoid duplication, the notification should update if it’s already displayed.
🤔 Expected Behavior?
ToastQueue provides additional tools for updating and avoiding duplication
😯 Current Behavior
At the moment, no other tool has such functionality.
💁 Possible Solution
No response
🔦 Context
I resolved the duplication issue by including the ID in the options. I then check if this ID already exists in the toast array. If it’s not present, I add it to the queue.
I also implemented update functionality. While it works to some extent—updating the content—the changes only take effect when the queue is refreshed or the container is focused.
💻 Examples
No response
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response