From 9bb7039b8874e1d3577ffff992dfdf5fe1bb5833 Mon Sep 17 00:00:00 2001 From: Clara Castillo Date: Tue, 20 Feb 2024 23:16:22 +0100 Subject: [PATCH] fix: clear timeout before pausing toast timer --- libs/ngx-sonner/src/lib/toast.component.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/ngx-sonner/src/lib/toast.component.ts b/libs/ngx-sonner/src/lib/toast.component.ts index 8c6f843..789b501 100644 --- a/libs/ngx-sonner/src/lib/toast.component.ts +++ b/libs/ngx-sonner/src/lib/toast.component.ts @@ -318,7 +318,7 @@ export class ToastComponent implements AfterViewInit, OnDestroy { } }); - effect(() => { + effect(onCleanup => { if (!this.isPromiseLoadingOrInfiniteDuration()) { if (this.expanded() || this.interacting()) { this.pauseTimer(); @@ -326,6 +326,8 @@ export class ToastComponent implements AfterViewInit, OnDestroy { this.startTimer(); } } + + onCleanup(() => clearTimeout(this.timeoutId)); }); effect(() => {