From 1d96d321b6f90fb261cb92e56ab39ec612d4aa3d Mon Sep 17 00:00:00 2001 From: TimJ0212 Date: Tue, 5 Apr 2022 19:35:50 +0200 Subject: [PATCH] fix: Test if active before reducing number of active toasts #922 (#926) --- src/lib/toastr/toastr.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/toastr/toastr.service.ts b/src/lib/toastr/toastr.service.ts index d936dfdc..3ce0dacc 100644 --- a/src/lib/toastr/toastr.service.ts +++ b/src/lib/toastr/toastr.service.ts @@ -113,7 +113,9 @@ export class ToastrService { } found.activeToast.toastRef.close(); this.toasts.splice(found.index, 1); - this.currentlyActive = this.currentlyActive - 1; + if(this.toasts[this.currentlyActive]) { + this.currentlyActive = this.currentlyActive - 1; + } if (!this.toastrConfig.maxOpened || !this.toasts.length) { return false; }