From 75e452a7813606ea4e0bf068892b3ccbf1c1f37e Mon Sep 17 00:00:00 2001 From: Christian Gil Date: Fri, 22 Mar 2024 20:52:07 -0600 Subject: [PATCH] feat(AlertDialog): Allow submit action to choose if closes the dialog --- src/runtime/components/overlays/AlertDialog.vue | 4 ++-- src/runtime/types/alert-dialog.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime/components/overlays/AlertDialog.vue b/src/runtime/components/overlays/AlertDialog.vue index 9e74fe2..d011dde 100644 --- a/src/runtime/components/overlays/AlertDialog.vue +++ b/src/runtime/components/overlays/AlertDialog.vue @@ -57,8 +57,8 @@ async function handleConfirm() { loading.value = true; try { - await props.confirmBtn.action(); - $open.value = false; + const shouldClose = await props.confirmBtn.action(); + if (shouldClose !== false) $open.value = false; } catch (error) { console.error('Unhandled error on alert dialog:', error); } diff --git a/src/runtime/types/alert-dialog.d.ts b/src/runtime/types/alert-dialog.d.ts index e0e45d0..633cce5 100644 --- a/src/runtime/types/alert-dialog.d.ts +++ b/src/runtime/types/alert-dialog.d.ts @@ -20,7 +20,7 @@ export interface AlertDialogProps { confirmBtn?: { label?: string; variant?: ButtonVariant; - action?: (() => void) | (() => Promise); + action?: (() => boolean | void) | (() => Promise); }; cancelBtn?: { label?: string;