From 3a52b5b9033bba50921d60999618ae467b9a92ea Mon Sep 17 00:00:00 2001 From: Maxime Fafard Date: Thu, 1 Dec 2022 11:06:06 -0500 Subject: [PATCH] Fix popover click outside handler when clicking siblings --- docs/src/pages/components/Popover.svx | 6 +++ .../pages/framed/Popover/WithButton.svelte | 37 +++++++++++++++++++ src/Popover/Popover.svelte | 4 +- types/Popover/Popover.svelte.d.ts | 2 +- 4 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 docs/src/pages/framed/Popover/WithButton.svelte diff --git a/docs/src/pages/components/Popover.svx b/docs/src/pages/components/Popover.svx index 03f1da78..d756b572 100644 --- a/docs/src/pages/components/Popover.svx +++ b/docs/src/pages/components/Popover.svx @@ -36,6 +36,12 @@ Set `closeOnOutsideClick` to set `open` to `false` when clicking outside of the +## Manage open state with a Button + +You can bind the `open` prop and manage the open state of the popover with an external button. + + + ## Popover alignment Customize the popover alignment using the `align` prop. Valid values include: `"top" | "top-left" | "top-right" | "bottom" | "bottom-left" | "bottom-right" | "left" | "left-bottom" | "left-top" | "right" | "right-bottom" | "right-top"`. diff --git a/docs/src/pages/framed/Popover/WithButton.svelte b/docs/src/pages/framed/Popover/WithButton.svelte new file mode 100644 index 00000000..fd3b6951 --- /dev/null +++ b/docs/src/pages/framed/Popover/WithButton.svelte @@ -0,0 +1,37 @@ + + +
+
+ + +
Content
+
+
+
+
+ Anim eu laboris veniam in est elit ullamco enim irure id. Lorem est culpa ex + in enim enim. Culpa quis incididunt magna officia et aliqua. Ullamco deserunt + aute enim cupidatat. Culpa quis enim sint sint anim qui irure exercitation labore + occaecat in reprehenderit proident. Nisi laborum ut et amet commodo amet ullamco + commodo non aliqua magna ad eu. Ad aliquip minim nostrud id enim elit velit ullamco + pariatur eu excepteur pariatur cillum. +
+
diff --git a/src/Popover/Popover.svelte b/src/Popover/Popover.svelte index 2287a72d..c26bc525 100644 --- a/src/Popover/Popover.svelte +++ b/src/Popover/Popover.svelte @@ -33,8 +33,8 @@ }, + { ["click:outside"]: CustomEvent<{ target: HTMLElement }> }, { default: {} } > {}