From e80829f282ec44b19ab18e57ecddacba34810323 Mon Sep 17 00:00:00 2001 From: Abdo Date: Wed, 13 Aug 2025 11:53:33 +0300 Subject: [PATCH] Fix Modal event handlers not working --- ts/lib/components/Modal.svelte | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ts/lib/components/Modal.svelte b/ts/lib/components/Modal.svelte index ca751208c..443595fc5 100644 --- a/ts/lib/components/Modal.svelte +++ b/ts/lib/components/Modal.svelte @@ -12,10 +12,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html export let modalKey: string = Math.random().toString(36).substring(2); export const dialogClass: string = ""; - export const onOkClicked: () => void = () => {}; - export const onCancelClicked: () => void = () => {}; - export const onShown: () => void = () => {}; - export const onHidden: () => void = () => {}; + export let onOkClicked: (() => void) | undefined = undefined; + export let onCancelClicked: (() => void) | undefined = undefined; + export let onShown: (() => void) | undefined = undefined; + export let onHidden: (() => void) | undefined = undefined; const modals = getContext>(modalsKey); @@ -24,12 +24,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html function onOkClicked_(): void { modal.hide(); - onOkClicked(); + onOkClicked?.(); } function onCancelClicked_(): void { modal.hide(); - onCancelClicked(); + onCancelClicked?.(); } export function show(): void { @@ -47,12 +47,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html function onShown_() { setModalOpen(true); - onShown(); + onShown?.(); } function onHidden_() { setModalOpen(false); - onHidden(); + onHidden?.(); } onMount(() => {