fkhadra / react-toastify

React notification made easy 🚀 !
https://fkhadra.github.io/react-toastify/introduction
MIT License
12.33k stars 676 forks source link

Multiple stacked toasts outside viewport #1028

Closed CalvinJamesHeath closed 6 months ago

CalvinJamesHeath commented 6 months ago

On a social network app, I was using toasts to show notifications. The problem is, if a user receives a lot of inquiries, only 6-7 will fit on the screen, and toasting them all at once prevents you from scrolling down to see the remaining ones.

To view the remaining toasts, one would want to scroll down.

fkhadra commented 6 months ago

Hey @CalvinJamesHeath do you have a screenshot or a video? Just want to see how I could address the issue

CalvinJamesHeath commented 6 months ago
Screenshot 2023-12-08 at 6 46 40 PM
sebakthapa commented 6 months ago

Quick Fix

Only a simple UI fix for such overflowing toasts.

There is a limit option in the <ToastContainer />.

<ToastContainer
 ...otherOptions
 limit={5}
/>

This limits the number of the toasts to be displayed. All the overflowing toasts will be queued and will be displayed after at least one of the 5 toast is closed (or closes automatically).

However, user have to wait for new toasts to appear on the viewport if the toast count exceeds the limit count. They can't scroll to view the queued toasts.

CalvinJamesHeath commented 6 months ago

That works great thank you guys @sebakthapa and @fkhadra 👏🏼

sebakthapa commented 6 months ago

I'm glad to hear that it's working well. If you have any further questions or issues, feel free to let us know. 😊