Skip to content

Commit

Permalink
feat(notification): add null autoCloseDelay (#698)
Browse files Browse the repository at this point in the history
Co-authored-by: Кононенко Артем Игоревич <AIKononenko@alfabank.ru>
  • Loading branch information
Artess999 and Кононенко Артем Игоревич committed Jun 17, 2021
1 parent 0a3bab5 commit 6c2f0e0
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/notification/src/Component.tsx
Expand Up @@ -34,7 +34,7 @@ export type NotificationProps = ToastPlateProps & {
/**
* Время до закрытия компонента
*/
autoCloseDelay?: number;
autoCloseDelay?: number | null;

/**
* Использовать портал
Expand Down Expand Up @@ -98,11 +98,13 @@ export const Notification = forwardRef<HTMLDivElement, NotificationProps>(
const [isClosing, setIsClosing] = useState(false);

const startAutoCloseTimer = useCallback(() => {
autoCloseTimeoutRef.current = window.setTimeout(() => {
if (onCloseTimeout) {
onCloseTimeout();
}
}, autoCloseDelay);
if (autoCloseDelay !== null) {
autoCloseTimeoutRef.current = window.setTimeout(() => {
if (onCloseTimeout) {
onCloseTimeout();
}
}, autoCloseDelay);
}
}, [autoCloseDelay, onCloseTimeout]);

const stopAutoCloseTimer = useCallback(() => {
Expand Down

0 comments on commit 6c2f0e0

Please sign in to comment.