mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
feat(ui-shell): add preventCloseOnClickOutside
to HeaderAction
(#1625)
Closes #1624
This commit is contained in:
parent
9b3f014a0b
commit
ea9b261b60
4 changed files with 36 additions and 9 deletions
|
@ -38,6 +38,9 @@
|
|||
*/
|
||||
export let transition = { duration: 200 };
|
||||
|
||||
/** Set to `true` to prevent the panel from closing when clicking outside */
|
||||
export let preventCloseOnClickOutside = false;
|
||||
|
||||
import { createEventDispatcher } from "svelte";
|
||||
import { slide } from "svelte/transition";
|
||||
import Close from "../icons/Close.svelte";
|
||||
|
@ -50,7 +53,12 @@
|
|||
|
||||
<svelte:window
|
||||
on:click="{({ target }) => {
|
||||
if (isOpen && !ref.contains(target) && !refPanel.contains(target)) {
|
||||
if (
|
||||
isOpen &&
|
||||
!ref.contains(target) &&
|
||||
!refPanel.contains(target) &&
|
||||
!preventCloseOnClickOutside
|
||||
) {
|
||||
isOpen = false;
|
||||
dispatch('close');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue