From e2fe2798421cb836732452c845a353cf32b13a93 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 27 Feb 2024 14:30:21 +0000 Subject: [PATCH] Exclude drawers from click_outside callbacks, unless registered inside a drawer --- packages/bbui/src/Actions/click_outside.js | 7 +++ packages/bbui/src/Drawer/Drawer.svelte | 59 ++++++++++------------ 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/packages/bbui/src/Actions/click_outside.js b/packages/bbui/src/Actions/click_outside.js index 1961dca47c..62416ae88d 100644 --- a/packages/bbui/src/Actions/click_outside.js +++ b/packages/bbui/src/Actions/click_outside.js @@ -32,6 +32,13 @@ const handleClick = event => { return } + // Ignore clicks for drawers, unless the handler is registered from a drawer + const sourceInDrawer = handler.anchor.closest(".drawer-container") != null + const clickInDrawer = event.target.closest(".drawer-container") != null + if (clickInDrawer && !sourceInDrawer) { + return + } + handler.callback?.(event) }) } diff --git a/packages/bbui/src/Drawer/Drawer.svelte b/packages/bbui/src/Drawer/Drawer.svelte index 5c80e4c84c..672795e078 100644 --- a/packages/bbui/src/Drawer/Drawer.svelte +++ b/packages/bbui/src/Drawer/Drawer.svelte @@ -46,13 +46,14 @@ } observer?.disconnect() observer = null + modal.set(false) } {#if visible} - {#if $modal} -
- {/if} -
0} - class:modal={$modal} - transition:slide|local - {style} - > -
-
{title || "Bindings"}
-
- - -
-
- - {#if !$modal && depth > 0} -
+
+ {#if $modal} +
{/if} +
0} + class:modal={$modal} + transition:slide|local + {style} + > +
+
{title || "Bindings"}
+
+ + +
+
+ + {#if !$modal && depth > 0} +
+ {/if} +
{/if}