Skip to content

Commit

Permalink
[core] fix: get toasters for timeout Infinity to match that of timeou…
Browse files Browse the repository at this point in the history
…t 0 behavior (palantir#6742)
  • Loading branch information
JML321 committed Nov 12, 2024
1 parent 08c0376 commit c164181
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/core/src/components/toast/toast2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export const Toast2 = React.forwardRef<HTMLDivElement, ToastProps>((props, ref)
const clearTimeout = React.useCallback(() => setIsTimeoutStarted(false), []);

// Per docs: "Providing a value less than or equal to 0 will disable the timeout (this is discouraged)."
const isTimeoutEnabled = timeout != null && timeout > 0;
// Per github, issue 6742: "timeout: Infinity should also behave the same as timeout: 0"
const isTimeoutEnabled = timeout != null && timeout > 0 && timeout !== Infinity;

// timeout is triggered & cancelled by updating `isTimeoutStarted` state
useTimeout(
Expand Down

0 comments on commit c164181

Please sign in to comment.