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

Closing hidden toast show more toasts than maxOpened allows #922

Closed
trpharove opened this issue Feb 16, 2022 · 2 comments · Fixed by #926
Closed

Closing hidden toast show more toasts than maxOpened allows #922

trpharove opened this issue Feb 16, 2022 · 2 comments · Fixed by #926
Labels

Comments

@trpharove
Copy link

My global settings are

ToastrModule.forRoot({
	newestOnTop: false,
	tapToDismiss: true,
	positionClass: 'toast-bottom-right',
	maxOpened: 5
}),

I made a bit of code to store all the generated toasts with a given key, for example for a warning :

const activeToast = this._toastManager.warning(content, title, { disableTimeOut: true });
activeToast.onHidden.pipe(take(1)).subscribe(() => this._toastMap.delete(key));
this._toastMap.set(key, activeToast);

in order to be able to remove a toast without the need to manually click on it using the key, like so :

this._toastManager.remove(this._toastMap.get(key).toastId);
this._toastMap.delete(key);

Mainly to allow a toast to be closed on a user action, like solving the reason the toast was added to the queue.

Right now, when I clear a toast that is not currently shown to the screen it (wrongly?) reduces the amount of currentlyActive toasts, causing the amount of toasts on screen to go above the maxOpened value.

@TimJ0212
Copy link
Contributor

TimJ0212 commented Apr 5, 2022

Hello, first-time contributor here. I looked in the code and found the problem. In the toastr.service.ts the remove function reduce the number of current active toasts before testing if the toast even is active. I opened a PR.

@scttcper
Copy link
Owner

scttcper commented Apr 5, 2022

🎉 This issue has been resolved in version 14.2.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

3 participants