Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/OverflowMenu/OverflowMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
/** Obtain a reference to the overflow menu element */
export let menuRef = null;

/** Persist the open state when click the items */
export let persistentClickItems = true;

import {
createEventDispatcher,
getContext,
Expand Down Expand Up @@ -202,8 +205,11 @@
class:bx--overflow-menu--xl="{size === 'xl'}"
{...$$restProps}
on:click
on:click="{({ target }) => {
if (!(menuRef && menuRef.contains(target))) {
on:click="{(e) => {
if (persistentClickItems) {
e.stopPropagation(); // this propagate to window.click to cause close
}
if (!(menuRef && menuRef.contains(e.target))) {
open = !open;
if (!open) dispatch('close');
}
Expand Down
6 changes: 6 additions & 0 deletions types/OverflowMenu/OverflowMenu.svelte.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export interface OverflowMenuProps extends RestProps {
*/
flipped?: boolean;

/**
* Set to `true` to keep menu open after clicking the items
* @default false
*/
persistentClickItems?: boolean;

/**
* Specify the menu options class
* @default undefined
Expand Down