Hello!
I am trying to prevent showing duplicated toasts using custom toastId. I am using autoClose option (2000ms). After multiple calls to e.g. toast.error() with same toastId feature works perfectly - only the first toast is being displayed. However, when autoClose time is finished and toast is ready to be closed - calling the toast.error() function results with showing the same toast once again, but this time with no autoClose timer. I deducted from experiments, that this occurs precisely when toast function is called during closing animation of the previous toast. Here is CodeSandbox snippet - to reproduce just start hitting 'Toast' button near active toast timer finish.
This bug does not appear when I am using isActive() function to prevent duplicates, however combining isActive() and setting custom toastId still causes above unwanted behaviour. For the design reasons it is important for me to be able to prevent duplicates using custom toastId, cause managing auto generated ids will quickly become quite a pain.
Thanks in advance!
hey @JanuszBartosz,
I tried both pen, I need to investigate to figure out what is going on.
I see the same behaviour if the following is called in quick succession. The .dismiss(2) call is not working consistently. (I think it might be the same issue?) Here's a sandbox to demo: it works with a 2000ms timeout, but not 200ms:
notifyWarn(msg: string) {
if (msg === "") {
toast.dismiss(2);
} else if (!toast.isActive(2)) {
toast(msg, { toastId: 2, type: toast.TYPE.WARNING });
} else {
toast.update(2, { render: msg, type: toast.TYPE.WARNING });
}
}
Same issue here. After the toast disappears automatically and I try to show it again quickly after, then it won't show up with animation and autoClose doesn't work on it, and the progress bar doesn't show up. This only happens if I try to show the toast again quickly after the first one auto closes.
if (!toast.isActive('designer_refresh')) {
toast('test', {
toastId: 'designer_refresh',
position: 'top-right',
autoClose: 2000,
hideProgressBar: false,
closeOnClick: true,
// pauseOnHover: true,
draggable: true,
className: 'notificationToolTip',
});
}
Hello everyone,
I think I know where the bug is coming from. I'll be able to work on it in 2 weeks.
Hi. Any update on this? Thanks!
i have same problem, when i click more one time and consecutive, toast do not disappear although i'm using {autoClose:4000} ? thanks
i updated new version, problem fix. Thanks so much.
@JanuszBartosz did you try to upgrade to the latest version and see if the issue if fixed for you ?
Yes, it works alright now :slightly_smiling_face: Thank you for your support!
Thank you @fkhadra, much appreciated!
Most helpful comment
Hello everyone,
I think I know where the bug is coming from. I'll be able to work on it in 2 weeks.