diff --git a/packages/core/src/components/toast/toast2.tsx b/packages/core/src/components/toast/toast2.tsx index f726528cb6..3d7d54615c 100644 --- a/packages/core/src/components/toast/toast2.tsx +++ b/packages/core/src/components/toast/toast2.tsx @@ -43,8 +43,7 @@ export const Toast2 = React.forwardRef((props, ref) const startTimeout = React.useCallback(() => setIsTimeoutStarted(true), []); 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; + const isTimeoutEnabled = timeout != null && timeout > 0 && timeout !== Infinity; // timeout is triggered & cancelled by updating `isTimeoutStarted` state useTimeout( diff --git a/packages/core/src/components/toast/toastProps.ts b/packages/core/src/components/toast/toastProps.ts index 63cc02577d..5a70be7385 100644 --- a/packages/core/src/components/toast/toastProps.ts +++ b/packages/core/src/components/toast/toastProps.ts @@ -47,7 +47,7 @@ export interface ToastProps extends Props, IntentProps { /** * Milliseconds to wait before automatically dismissing toast. - * Providing a value less than or equal to 0 will disable the timeout (this is discouraged). + * Providing a value less than or equal to 0 or Infinity will disable the timeout (this is discouraged). * * @default 5000 */ diff --git a/packages/core/test/toast/toast2Tests.tsx b/packages/core/test/toast/toast2Tests.tsx index adab602202..6e843fea7a 100644 --- a/packages/core/test/toast/toast2Tests.tsx +++ b/packages/core/test/toast/toast2Tests.tsx @@ -98,5 +98,13 @@ describe("", () => { done(); }, 20); }); + + it("timeout={Infinity} behaves same as timeout={0} and does not trigger onDismiss", done => { + mount(); + setTimeout(() => { + assert.isTrue(handleDismiss.notCalled, "onDismiss was called when it should not have been"); + done(); + }, 20); + }); }); });