iamhosseindhv / notistack

Highly customizable notification snackbars (toasts) that can be stacked on top of each other
https://notistack.com
Other
3.89k stars 299 forks source link

Option for separate maxSnack when persist: true ? #557

Open Ben-CA opened 1 year ago

Ben-CA commented 1 year ago

I have an application that uses Notistack, and it provides notifications on successes and failures. (e.g. API calls completed)

For successes, I have no persist setting (default: false), and I'd like the maxSnack=3. (They are also dismissible.)

However, for failures, there could be 10, and these are set to persist: true, and I'd like it to only show the most recent 3, but when one is dismissed, keep showing the remainder until all the errors have been seen and manually dismissed.

Ideally, there would be a "hidden queue", so it's only showing 3, but there could be dozens of errors being logged, and then you can cycle through them dismissing them.

Alternately, a second option would be having a separate (higher) count for persisted notifications - so the maxSnack=3 for "regular", and maxSnack=10 for persisted.

Does this make sense? Perhaps I missed something in the documentation, but I'm not seeing a way to support such.

When I have more than the maxSnack with persisted notifications, it throws a console error like this currently and disposes of the prior ones (as noted in the documentation):

image

rene-stesl commented 8 months ago

+1 Would love to see such option. Usually I don't want to show more than 3 Snackbars, but if there are 3 Snackbars with the persist flag, I don't want to lose them and show e.g. 2 more additional Snackbars to the persited ones if new Snackbars should be shown. It would be great if the persisted ones could be grouped together in the stack.