From 30dda73e9078bbccf91c3f43307250c84a17e8bd Mon Sep 17 00:00:00 2001 From: Aman Harwara Date: Thu, 5 Jan 2023 00:13:42 +0530 Subject: [PATCH] fix: Fixed issue where file upload toast would close before completion if you switched windows --- packages/toast/src/ToastTimer.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/toast/src/ToastTimer.tsx b/packages/toast/src/ToastTimer.tsx index 483448cc8..9d4698668 100644 --- a/packages/toast/src/ToastTimer.tsx +++ b/packages/toast/src/ToastTimer.tsx @@ -27,8 +27,12 @@ export const ToastTimer: FunctionComponent = ({ toast, index }) => { const remainingTimeRef = useRef(duration) const dismissToastOnEnd = useCallback(() => { + if (!shouldAutoClose) { + return + } + dismissToast(toast.id) - }, [toast.id]) + }, [shouldAutoClose, toast.id]) const clearTimer = useCallback(() => { if (toastTimerIdRef.current) {