From f9b59756da9c4aeebc08c5eb62c0efef98fa9c9a Mon Sep 17 00:00:00 2001 From: Tim Auf dem Kampe Date: Wed, 15 Jan 2025 13:26:07 +0100 Subject: [PATCH] fix(Notification): Fix "Timer not started" error for notifications that should not auto close (#1101) Co-authored-by: Tim Auf dem Kampe --- .../ControlledNotification.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/components/src/components/NotificationProvider/ControlledNotification.tsx b/packages/components/src/components/NotificationProvider/ControlledNotification.tsx index 577cf8206..37679e7d8 100644 --- a/packages/components/src/components/NotificationProvider/ControlledNotification.tsx +++ b/packages/components/src/components/NotificationProvider/ControlledNotification.tsx @@ -15,20 +15,28 @@ export const ControlledNotification: FC = (props) => { return cloneElement(notification.element, { onMouseEnter: () => { - notification.meta.autoCloseTimer.pause(); + if (notification.element.props.autoClose) { + notification.meta.autoCloseTimer.pause(); + } }, onMouseLeave: () => { - notification.meta.autoCloseTimer.resume(); + if (notification.element.props.autoClose) { + notification.meta.autoCloseTimer.resume(); + } }, onClose: () => { controller.remove(notification.meta.id); notification.element.props.onClose?.(); }, onFocus: () => { - notification.meta.autoCloseTimer.pause(); + if (notification.element.props.autoClose) { + notification.meta.autoCloseTimer.pause(); + } }, onBlur: () => { - notification.meta.autoCloseTimer.resume(); + if (notification.element.props.autoClose) { + notification.meta.autoCloseTimer.resume(); + } }, }); };