Skip to content

Commit

Permalink
Only close Dialog/Drawer on direct Backdrop click (not drag from Dial…
Browse files Browse the repository at this point in the history
…og/Drawer to Backdrop)
  • Loading branch information
techniq committed Sep 9, 2023
1 parent 161b728 commit acc3255
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-frogs-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte-ux': patch
---

Only close Dialog/Drawer on direct Backdrop click (not drag from Dialog/Drawer to Backdrop)
8 changes: 5 additions & 3 deletions src/lib/components/Dialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@

{#if open}
<Backdrop
on:mouseup={(e) => {
// Do not allow event to reach Popover's on:mouseup (clickOutside)
e.stopPropagation();
on:click={() => {
if (!persistent) {
open = false;
}
dispatch('close-attempt');
}}
on:mouseup={(e) => {
// Do not allow event to reach Popover's on:mouseup (clickOutside)
e.stopPropagation();
}}
class={cls('z-50', theme.backdrop, classes.backdrop)}
fadeParams={{ duration: 150 }}
{portal}
Expand Down
8 changes: 5 additions & 3 deletions src/lib/components/Drawer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@

{#if open}
<Backdrop
on:mouseup={(e) => {
// Do not allow event to reach Popover's on:mouseup (clickOutside)
e.stopPropagation();
on:click={(e) => {
if (!persistent) {
open = false;
}
dispatch('close-attempt');
}}
on:mouseup={(e) => {
// Do not allow event to reach Popover's on:mouseup (clickOutside)
e.stopPropagation();
}}
class={cls('z-50', theme.backdrop, classes.backdrop)}
{portal}
/>
Expand Down

1 comment on commit acc3255

@vercel
Copy link

@vercel vercel bot commented on acc3255 Sep 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.