Fix Modal event handlers not working

This commit is contained in:
Abdo 2025-08-13 11:53:33 +03:00
parent 3f6d904236
commit e80829f282

View file

@ -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 let modalKey: string = Math.random().toString(36).substring(2);
export const dialogClass: string = ""; export const dialogClass: string = "";
export const onOkClicked: () => void = () => {}; export let onOkClicked: (() => void) | undefined = undefined;
export const onCancelClicked: () => void = () => {}; export let onCancelClicked: (() => void) | undefined = undefined;
export const onShown: () => void = () => {}; export let onShown: (() => void) | undefined = undefined;
export const onHidden: () => void = () => {}; export let onHidden: (() => void) | undefined = undefined;
const modals = getContext<Map<string, Modal>>(modalsKey); const modals = getContext<Map<string, Modal>>(modalsKey);
@ -24,12 +24,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
function onOkClicked_(): void { function onOkClicked_(): void {
modal.hide(); modal.hide();
onOkClicked(); onOkClicked?.();
} }
function onCancelClicked_(): void { function onCancelClicked_(): void {
modal.hide(); modal.hide();
onCancelClicked(); onCancelClicked?.();
} }
export function show(): void { export function show(): void {
@ -47,12 +47,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
function onShown_() { function onShown_() {
setModalOpen(true); setModalOpen(true);
onShown(); onShown?.();
} }
function onHidden_() { function onHidden_() {
setModalOpen(false); setModalOpen(false);
onHidden(); onHidden?.();
} }
onMount(() => { onMount(() => {