Skip to content

Commit e3524b6

Browse files
committed
fix: alert confirm state in beforeClose callback
1 parent b985ff0 commit e3524b6

File tree

1 file changed

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

1 file changed

+7
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ function onAlertClosed() {
4747
isConfirm.value = false;
4848
}
4949
50+
function onEscapeKeyDown() {
51+
isConfirm.value = false;
52+
}
53+
5054
const getIconRender = computed(() => {
5155
let iconRender: Component | null = null;
5256
if (props.icon) {
@@ -116,13 +120,11 @@ function handleCancel() {
116120
117121
const loading = ref(false);
118122
async function handleOpenChange(val: boolean) {
119-
const confirmState = isConfirm.value;
120-
isConfirm.value = false;
121-
await nextTick();
123+
await nextTick(); // 等待标记isConfirm状态
122124
if (!val && props.beforeClose) {
123125
loading.value = true;
124126
try {
125-
const res = await props.beforeClose({ isConfirm: confirmState });
127+
const res = await props.beforeClose({ isConfirm: isConfirm.value });
126128
if (res !== false) {
127129
open.value = false;
128130
}
@@ -142,6 +144,7 @@ async function handleOpenChange(val: boolean) {
142144
:overlay-blur="overlayBlur"
143145
@opened="emits('opened')"
144146
@closed="onAlertClosed"
147+
@escape-key-down="onEscapeKeyDown"
145148
:class="
146149
cn(
147150
containerClass,

0 commit comments

Comments
 (0)