Skip to content

Commit

Permalink
fix: added type check for currentId
Browse files Browse the repository at this point in the history
  • Loading branch information
thedivtagguy committed Nov 4, 2024
1 parent 1362456 commit 2565ae7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/lib/vaul/components/root.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,14 @@

const $openDialogIds = get(openDrawerIds);
const currentId = get(drawerId);
// Find the index of the current drawer
const currentIndex = $openDialogIds.indexOf(currentId);
// Only close if this is the topmost drawer
if (currentIndex === $openDialogIds.length - 1) {
onOpenChange?.(false);
closeDrawer();
if (currentId) {
// Find the index of the current drawer
const currentIndex = $openDialogIds.indexOf(currentId);
// Only close if this is the topmost drawer
if (currentIndex === $openDialogIds.length - 1) {
onOpenChange?.(false);
closeDrawer();
}
}
}}
{...$$restProps}
Expand Down

0 comments on commit 2565ae7

Please sign in to comment.