From b7ed85e23ff89a41cd43aed44fbc6fa2c54f9aa2 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sat, 18 Apr 2026 09:14:28 +0000 Subject: fix(notification): clear auto-dismiss timer on component destroy onMount scheduled a setTimeout to auto-dismiss the notification after notification.duration ms but never stored the handle. If the component was destroyed before the timer fired (parent unmount, navigation), the timer still ran and called remove() on a stale closure. Capture the timer id and clear it from the onMount cleanup callback. --- src/lib/Notification/Notification.svelte | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/Notification/Notification.svelte b/src/lib/Notification/Notification.svelte index 76775ff3..a3271d58 100644 --- a/src/lib/Notification/Notification.svelte +++ b/src/lib/Notification/Notification.svelte @@ -9,7 +9,11 @@ export let onRemove: () => void = () => { }; export let removed = false; -onMount(() => setTimeout(remove, notification.duration)); +onMount(() => { + const removeTimer = setTimeout(remove, notification.duration); + + return () => clearTimeout(removeTimer); +}); const remove = () => { removed = true; -- cgit v1.2.3