Skip to content

Commit

Permalink
fix(ui): manually implement close-on-outside-click feature for modals
Browse files Browse the repository at this point in the history
1. use `pointer-events-auto` to allow backdrop layer to receive event
2. bind a onclick to the backdrop layer
  • Loading branch information
CNSeniorious000 authored May 10, 2023
1 parent 5add915 commit 115094d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/ui/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default (props: Props) => {
<Show when={api().isOpen}>
<div class="fixed inset-0 z-20 fcc">
<Portal>
<div {...api().backdropProps} class="fixed inset-0 bg-base opacity-60" />
<div {...api().backdropProps} class="fixed inset-0 bg-base opacity-60 pointer-events-auto" onclick={() => api().close()} />
</Portal>
<div {...api().containerProps}>
<div {...api().contentProps} class={`bg-base-100 transition-transform ease-out max-w-screen max-h-screen overflow-auto border-base shadow-lg ${containerBaseClass}`}>
Expand Down

0 comments on commit 115094d

Please sign in to comment.