From 6f0c829d36671293c15074095d5366eb6f97521b Mon Sep 17 00:00:00 2001 From: Chris Sherwood Date: Sun, 18 Jan 2026 15:43:48 -0800 Subject: [PATCH] fix: Notification auto-dismiss not working due to stale closure The removeNotification function was using a stale reference to the notifications array from the closure scope, causing the setTimeout callback to filter against an outdated state. Changed to use functional update pattern (prev => prev.filter(...)) which correctly references the current state when the timeout fires. Co-Authored-By: Claude Opus 4.5 --- admin/inertia/providers/NotificationProvider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/inertia/providers/NotificationProvider.tsx b/admin/inertia/providers/NotificationProvider.tsx index aa5d888..a8314ea 100644 --- a/admin/inertia/providers/NotificationProvider.tsx +++ b/admin/inertia/providers/NotificationProvider.tsx @@ -22,7 +22,7 @@ const NotificationsProvider = ({ children }: { children: React.ReactNode }) => { } const removeNotification = (id: string) => { - setNotifications(notifications.filter((n) => n.id !== id)) + setNotifications((prev) => prev.filter((n) => n.id !== id)) } const removeAllNotifications = () => {