From 1827964303b015a09aca99570a18744f406fd414 Mon Sep 17 00:00:00 2001 From: Tim Jungk Date: Tue, 5 Apr 2022 09:30:34 +0200 Subject: [PATCH] #922 Test if active before reducing the number of active toasts. --- 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; }