Merge commit '2657f30cf3acaa592408d2d4cddcb02bf76bb6af' into dev
✅ close #27
This commit is contained in:
commit
970a7c58d3
@ -1,5 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import { _ } from "svelte-i18n";
|
import { _ } from "svelte-i18n";
|
||||||
|
import { clickOutside } from "./outsideclick";
|
||||||
import { focusTrap } from "svelte-focus-trap";
|
import { focusTrap } from "svelte-focus-trap";
|
||||||
import { tracks as tracksstore } from "../store.js";
|
import { tracks as tracksstore } from "../store.js";
|
||||||
import { TrackService } from "@odit/lfk-client-js";
|
import { TrackService } from "@odit/lfk-client-js";
|
||||||
@ -76,11 +77,19 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if modal_open}
|
{#if modal_open}
|
||||||
<div class="fixed z-10 inset-0 overflow-y-auto" use:focusTrap>
|
<div
|
||||||
|
class="fixed z-10 inset-0 overflow-y-auto"
|
||||||
|
use:focusTrap
|
||||||
|
use:clickOutside
|
||||||
|
on:click_outside={() => {
|
||||||
|
modal_open = false;
|
||||||
|
}}>
|
||||||
<div
|
<div
|
||||||
class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
|
class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
|
||||||
<div class="fixed inset-0 transition-opacity" aria-hidden="true">
|
<div class="fixed inset-0 transition-opacity" aria-hidden="true">
|
||||||
<div class="absolute inset-0 bg-gray-500 opacity-75" />
|
<div
|
||||||
|
class="absolute inset-0 bg-gray-500 opacity-75"
|
||||||
|
data-id="modal_backdrop" />
|
||||||
</div>
|
</div>
|
||||||
<span
|
<span
|
||||||
class="hidden sm:inline-block sm:align-middle sm:h-screen"
|
class="hidden sm:inline-block sm:align-middle sm:h-screen"
|
||||||
|
10
src/components/outsideclick.js
Normal file
10
src/components/outsideclick.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/** Dispatch event on click outside of node */
|
||||||
|
export function clickOutside(node) {
|
||||||
|
const handleClick = (event) => {
|
||||||
|
if (event.target.getAttribute('data-id') === 'modal_backdrop') {
|
||||||
|
node.dispatchEvent(new CustomEvent('click_outside', node));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
document.removeEventListener('click', handleClick, true);
|
||||||
|
document.addEventListener('click', handleClick, true);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user