Skip to content

Commit

Permalink
feat(AlertDialog): Allow submit action to choose if closes the dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisGV04 committed Mar 23, 2024
1 parent 29cd307 commit 75e452a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/runtime/components/overlays/AlertDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/types/alert-dialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface AlertDialogProps<T> {
confirmBtn?: {
label?: string;
variant?: ButtonVariant;
action?: (() => void) | (() => Promise<void>);
action?: (() => boolean | void) | (() => Promise<boolean | void>);
};
cancelBtn?: {
label?: string;
Expand Down

0 comments on commit 75e452a

Please sign in to comment.