diff --git a/.changeset/sixty-cobras-suffer.md b/.changeset/sixty-cobras-suffer.md new file mode 100644 index 000000000..1112d603b --- /dev/null +++ b/.changeset/sixty-cobras-suffer.md @@ -0,0 +1,5 @@ +--- +"bits-ui": patch +--- + +Fix: cleanup dialog timeout diff --git a/src/lib/bits/dialog/components/Dialog.svelte b/src/lib/bits/dialog/components/Dialog.svelte index 928fdb42e..b5f1e61cc 100644 --- a/src/lib/bits/dialog/components/Dialog.svelte +++ b/src/lib/bits/dialog/components/Dialog.svelte @@ -31,24 +31,22 @@ transitionTimes, tOpen, onOpenChange: ({ next }) => { - if (isBrowser) { - window.clearTimeout(timeout); + if (!isBrowser) { + return next; } + window.clearTimeout(timeout); if (open !== next) { onOpenChange?.(next); } if (next !== $tOpen) { tOpen.set(next); if (!next) { - if (isBrowser) { - window.clearTimeout(timeout); - timeout = window.setTimeout( - () => { - localOpen.set(next); - }, - $transitionTimes.out ? $transitionTimes.out * 0.6 : 0 - ); - } + timeout = window.setTimeout( + () => { + localOpen.set(next); + }, + $transitionTimes.out ? $transitionTimes.out * 0.6 : 0 + ); open = !next; return !next; } else {