Skip to content

Commit 79de6bc

Browse files
authored
fix: alert send wrong confirm state to beforeClose (vbenjs#5991)
* 修复alert在按下Esc或者点击遮罩关闭时,可能发送错误的isConfirm状态
1 parent 14bd6dd commit 79de6bc

File tree

1 file changed

+5
-4
lines changed
  • packages/@core/ui-kit/popup-ui/src/alert

1 file changed

+5
-4
lines changed

packages/@core/ui-kit/popup-ui/src/alert/alert.vue

+5-4
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,13 @@ const getIconRender = computed(() => {
9191
});
9292
9393
function doCancel() {
94-
isConfirm.value = false;
94+
handleCancel();
9595
handleOpenChange(false);
9696
}
9797
9898
function doConfirm() {
99-
isConfirm.value = true;
99+
handleConfirm();
100100
handleOpenChange(false);
101-
emits('confirm');
102101
}
103102
104103
provideAlertContext({
@@ -117,11 +116,13 @@ function handleCancel() {
117116
118117
const loading = ref(false);
119118
async function handleOpenChange(val: boolean) {
119+
const confirmState = isConfirm.value;
120+
isConfirm.value = false;
120121
await nextTick();
121122
if (!val && props.beforeClose) {
122123
loading.value = true;
123124
try {
124-
const res = await props.beforeClose({ isConfirm: isConfirm.value });
125+
const res = await props.beforeClose({ isConfirm: confirmState });
125126
if (res !== false) {
126127
open.value = false;
127128
}

0 commit comments

Comments
 (0)