Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Limit the number of toast displayed at the same time #298

Closed
popuguytheparrot opened this issue Dec 26, 2018 · 25 comments
Closed

Feat: Limit the number of toast displayed at the same time #298

popuguytheparrot opened this issue Dec 26, 2018 · 25 comments
Assignees
Labels

Comments

@popuguytheparrot
Copy link

popuguytheparrot commented Dec 26, 2018

Do you want to request a feature or report a bug?
feature
What is the current behavior?
No limited on showing

What is the expected behavior?
Props to limited toast showing

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React v16.7

@fkhadra
Copy link
Owner

fkhadra commented Dec 31, 2018

Hello @popugang,

You can already pass a component and limit the output. For instance, lets do it with css and a functional component.

 .limited-output{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
// somewhere in your app
toast(() => (
  <div className="limited-output">
  Lorem ipsum dolor sit amet, consectetur adipisicing elit. Deserunt rem odit quis quaerat. In dolorem 
  praesentium velit ea esse consequuntur cum fugit sequi voluptas ut possimus voluptatibus deserunt 
  nisi eveniet!Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem voluptates vel dolorum 
  autem ex repudiandae iste quasi. Minima explicabo qui necessitatibus porro nihil aliquid deleniti ullam 
  repudiandae
</div>
);

You can find more about rendering a component here

@fkhadra fkhadra closed this as completed Dec 31, 2018
@popuguytheparrot
Copy link
Author

popuguytheparrot commented Jan 9, 2019

@fkhadra You do not understand me. I want to limit the notification showing.
i want props showCount={3} and watching only 3 toast on the site

@fkhadra
Copy link
Owner

fkhadra commented Jan 9, 2019

Hello @popugang,

You mean limit the number of toast displayed at the same time ?

@popuguytheparrot
Copy link
Author

Hello @popugang,

You mean limit the number of toast displayed at the same time ?

exactly

@popuguytheparrot
Copy link
Author

@fkhadra what can do with it ?

@popuguytheparrot
Copy link
Author

@fkhadra reopen issue please

@fkhadra
Copy link
Owner

fkhadra commented Jan 15, 2019

Hello @popugang,

Sorry I'm quite busy for the moment. I made a codesanbox to show you how you can limit the output. There is several ways to do it. The sandbox just give you the general idea.
Edit qq9rpr0269

@fkhadra fkhadra reopened this Jan 15, 2019
@fkhadra fkhadra changed the title Add option to limited output Feat: Limit the number of toast displayed at the same time Jan 15, 2019
@popuguytheparrot
Copy link
Author

@fkhadra thank you very much

@headfire94
Copy link

Will be cool to have a buffer that will store delayed notifications until we can show them

@Rafi993
Copy link

Rafi993 commented Mar 1, 2019

It would be awesome if this is available as an option in the toast container

@fkhadra fkhadra self-assigned this Mar 13, 2019
@mudrila
Copy link

mudrila commented May 14, 2019

@fkhadra Any progress on that so far? Maybe, you would need additional help?

@marcosandri-dev
Copy link

I need this feature too, to me it would be super cool to have n toasters and having the old ones to close automatically as the new ones appear!

@mrnguyentrantam
Copy link

I also need this feature

@HZSamir
Copy link

HZSamir commented Dec 30, 2019

I would love such a feature as well. Have to handle this myself for now.

@zslucky
Copy link

zslucky commented Jan 16, 2020

I faced same issue

@fkhadra
Copy link
Owner

fkhadra commented Jan 16, 2020

Hello guys,

I'm rewriting the library, maybe I'll port it to typescript. The goal is to reduce the bundle size and also to lower the barrier for newcomers. I'll see how to add this feature.

@rami-sweyri
Copy link

also i need this feature

@fkhadra fkhadra mentioned this issue Mar 8, 2020
Merged
8 tasks
@shubhamappstec
Copy link

also i need this feature

@taimoorgit
Copy link

+1; I'd love to have a maxCount I can pass to toast.configure()

@fkhadra fkhadra added the Merged in next Merged but not live label Apr 13, 2020
@fkhadra
Copy link
Owner

fkhadra commented Apr 22, 2020

Hey, a v6 release candidate is available including that feature. You can try it here

@zslucky
Copy link

zslucky commented Apr 28, 2020

@fkhadra great release, thank you so much. I have a scenario that need to display the latest limited toasts, and hide the oldest toasts, as my site need to push the latest real-time messages to users, queued toasts may delay some important informations... is it necessary support 2 modes for count limit? LRU and Queued?

@fkhadra
Copy link
Owner

fkhadra commented May 10, 2020

@zslucky the v6(not RC) is now live. Maybe this can help https://fkhadra.github.io/react-toastify/limit-the-number-of-toast-displayed/#how-to-clear-the-waiting-queue

@fkhadra fkhadra closed this as completed May 10, 2020
@zslucky
Copy link

zslucky commented May 12, 2020

@fkhadra thanks, this can be a solution. 👍

@mmesar
Copy link

mmesar commented Jul 14, 2021

Do we, maybe, have access to that queue. I am interested in a number of notifications in queue. Or, and I know this is not the topic, can we get number of currently displayed notifications. For example, I would like to display "dismiss all" button inside notification only when there are more than 3 notifications displayed (have searched for this feature but haven't found it, apologies if it exists, in that case plz point me in the right direction).

@Shielsy
Copy link

Shielsy commented Oct 4, 2023

I'm not using the ToastContainer but there doesn't seem a way to set the limit property programmatically. Will this be added? Also, a 'dismiss all' button would be nice as mentioned above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests