Skip to content

Commit

Permalink
[ButtonMenu]: Fix close handler
Browse files Browse the repository at this point in the history
  • Loading branch information
fallaciousreasoning committed Aug 12, 2024
1 parent e8b668f commit 5af67cb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/buttonMenu/buttonMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</script>

<script lang="ts">
import Menu, { type CloseEvent } from '../menu/menu.svelte'
import Menu, { type CloseEvent, type CloseEventDetail } from '../menu/menu.svelte'
import type { Strategy } from '@floating-ui/dom'
export let isOpen: boolean | undefined = undefined
Expand All @@ -31,6 +31,11 @@
if (isOpen === undefined) isOpenInternal = toggleTo
onChange?.({ isOpen: toggleTo })
}
const handleClose = (e: CloseEventDetail) => {
if (isOpen === undefined) isOpenInternal = false
onClose?.(e)
}
</script>

<div class="leo-button-menu">
Expand All @@ -42,7 +47,7 @@
<div bind:this={anchor} on:click|stopPropagation={toggle}>
<slot name="anchor-content"/>
</div>
<Menu {positionStrategy} isOpen={isOpenInternal} target={anchor} {onClose}>
<Menu {positionStrategy} isOpen={isOpenInternal} target={anchor} onClose={handleClose}>
<slot />
</Menu>
</div>
Expand Down

0 comments on commit 5af67cb

Please sign in to comment.