Skip to content

Commit

Permalink
fix: check activateClickOutside on outside click (#1082)
Browse files Browse the repository at this point in the history
handleClickOutside checks the state of activateClickOutside when called.
This allows setting activateClickOutside when the component is mounted.
  • Loading branch information
uherman authored and shinokada committed Sep 22, 2023
1 parent dbc7ae4 commit 283f1b3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib/drawer/Drawer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
hidden = !hidden;
};
const handleClickOutside = () => activateClickOutside && !hidden && handleDrawer();
let backdropDivClass = twMerge('fixed top-0 left-0 z-50 w-full h-full', backdrop && bgColor, backdrop && bgOpacity);
function clickOutsideWrapper(node: HTMLElement, callback: () => void) {
Expand All @@ -59,7 +61,7 @@
<div role="presentation" class={backdropDivClass} />
{/if}

<div use:clickOutsideWrapper={() => !hidden && handleDrawer()} {id} {...$$restProps} class={twMerge(divClass, width, position, placements[placement], $$props.class)} transition:multiple={transitionParams} tabindex="-1" aria-controls={id} aria-labelledby={id}>
<div use:clickOutsideWrapper={handleClickOutside} {id} {...$$restProps} class={twMerge(divClass, width, position, placements[placement], $$props.class)} transition:multiple={transitionParams} tabindex="-1" aria-controls={id} aria-labelledby={id}>
<slot {hidden} />
</div>
{/if}
Expand Down

0 comments on commit 283f1b3

Please sign in to comment.