Skip to content

Commit

Permalink
cleanup timeout (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte authored Aug 31, 2023
1 parent 721cb51 commit b66e02a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/sixty-cobras-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"bits-ui": patch
---

Fix: cleanup dialog timeout
20 changes: 9 additions & 11 deletions src/lib/bits/dialog/components/Dialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b66e02a

Please sign in to comment.