fix: alert send wrong confirm state to beforeClose (#5991)
* 修复alert在按下Esc或者点击遮罩关闭时,可能发送错误的isConfirm状态
This commit is contained in:
parent
14bd6dd25d
commit
79de6bcbf7
@ -91,14 +91,13 @@ const getIconRender = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function doCancel() {
|
function doCancel() {
|
||||||
isConfirm.value = false;
|
handleCancel();
|
||||||
handleOpenChange(false);
|
handleOpenChange(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function doConfirm() {
|
function doConfirm() {
|
||||||
isConfirm.value = true;
|
handleConfirm();
|
||||||
handleOpenChange(false);
|
handleOpenChange(false);
|
||||||
emits('confirm');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
provideAlertContext({
|
provideAlertContext({
|
||||||
@ -117,11 +116,13 @@ function handleCancel() {
|
|||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
async function handleOpenChange(val: boolean) {
|
async function handleOpenChange(val: boolean) {
|
||||||
|
const confirmState = isConfirm.value;
|
||||||
|
isConfirm.value = false;
|
||||||
await nextTick();
|
await nextTick();
|
||||||
if (!val && props.beforeClose) {
|
if (!val && props.beforeClose) {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const res = await props.beforeClose({ isConfirm: isConfirm.value });
|
const res = await props.beforeClose({ isConfirm: confirmState });
|
||||||
if (res !== false) {
|
if (res !== false) {
|
||||||
open.value = false;
|
open.value = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user