react-toastify icon indicating copy to clipboard operation
react-toastify copied to clipboard

No means to preemptively dismiss a single pending toast when limit != 0

Open JulianSelman opened this issue 10 months ago • 2 comments

Hello,

I have a use case where I want to dismiss a class of toasts at the same time (say, from a single event source that has disappeared), while leaving all others displayed or pending. I am using a ToastContainer with a limit of 2, so sometimes the toasts I want to dismiss early are still in the queue. There's a means to entirely clear the pending queue via toast.clearWaitingQueue, but this is too destructive for my needs as I want to preserve any waiting toasts that are not already filtered out.

I propose that toast.dismiss(id) be modified such that it not only dismisses any toast by that ID but also removes it from the pending queue. I think that should be sematically valid -- I can't think of a case where you'd want to dismiss a given toast but not also remove it from the pending queue if it's still there -- but if you prefer, I'd also be able to work with a toast.removeFromWaitingQueue(id) if the concepts should remain distinct.

I have a local commit that I can provide for PR that augments toast.dismiss(id) if you are amenable to this change.

Thank you for the excellent library!

JulianSelman avatar Apr 14 '25 22:04 JulianSelman

Here is a pull request for your consideration: #1235

JulianSelman avatar Apr 17 '25 08:04 JulianSelman

This is vital for anyone using limits while programmatically removing toasts. Thanks for the PR - hope to see it merged soon.

ajbeaven avatar Jun 30 '25 08:06 ajbeaven