From 975b6f30700eebc7902843911484a6c54387d0c3 Mon Sep 17 00:00:00 2001 From: pheralb Date: Tue, 23 Jul 2024 09:33:24 +0100 Subject: [PATCH] fix: improve handleCloseToast function in Toast component --- library/src/components/toast.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/library/src/components/toast.tsx b/library/src/components/toast.tsx index cf9e30e..1a1b195 100644 --- a/library/src/components/toast.tsx +++ b/library/src/components/toast.tsx @@ -41,11 +41,16 @@ const Toast = (props: ToastComponentProps) => { const handleCloseToast = () => { setIsExiting(true); - setTimeout(() => { - if (props.onClose) { - props.onClose(); - } - }, 300); + const animationDisabled = prefersReducedMotion(); + if (!animationDisabled) { + setTimeout(() => { + if (props.onClose) { + props.onClose(); + } + }, 300); + } else if (props.onClose) { + props.onClose(); + } }; const handleMouseLeave = () => {