fix empty popups

This commit is contained in:
2025-11-10 14:24:38 +01:00
parent 1d9488e6dd
commit 93b035159b
3 changed files with 16 additions and 4 deletions

View File

@@ -2,7 +2,7 @@
import { onDestroy } from 'svelte'; import { onDestroy } from 'svelte';
interface Props { interface Props {
end: Date, end: Date;
} }
let { end }: Props = $props(); let { end }: Props = $props();

View File

@@ -5,16 +5,22 @@
// html bindings // html bindings
let modal: HTMLDialogElement; let modal: HTMLDialogElement;
// state
let closeTimeoutId = $state(-1);
// lifecycle // lifecycle
const cancel = confirmPopupState.subscribe((value) => { const cancel = confirmPopupState.subscribe((value) => {
if (value) modal.show(); if (!value) return;
clearTimeout(closeTimeoutId);
modal.show();
}); });
onDestroy(cancel); onDestroy(cancel);
// callbacks // callbacks
function onModalClose() { function onModalClose() {
setTimeout(() => ($confirmPopupState = null), 300); closeTimeoutId = setTimeout(() => ($confirmPopupState = null), 300);
} }
</script> </script>

View File

@@ -5,9 +5,15 @@
// html bindings // html bindings
let modal: HTMLDialogElement; let modal: HTMLDialogElement;
// state
let closeTimeoutId = $state(-1);
// lifecycle // lifecycle
const cancel = popupState.subscribe((value) => { const cancel = popupState.subscribe((value) => {
if (value) modal.show(); if (!value) return;
clearTimeout(closeTimeoutId);
modal.show();
}); });
onDestroy(cancel); onDestroy(cancel);