From 3d74ef4d640acdc75e1facf91554deb6f7a1c556 Mon Sep 17 00:00:00 2001 From: Zhanjiachun <49758402+Zhanjiachun@users.noreply.github.com> Date: Thu, 31 Aug 2023 17:20:33 +0800 Subject: [PATCH] Fix0817 (#2708) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 弹窗组件如果初始默认显示, 按esc关不掉问题修复 (#2608) * fix: 弹窗组件如果初始默认显示, 按esc关不掉问题修复 (#2608) * fix: 弹窗组件如果初始默认显示, 按esc关不掉问题修复 (#2608) * fix: 弹窗组件如果初始默认显示, 按esc关不掉问题修复 (#2608) * fix: 弹窗组件如果初始默认显示, 按esc关不掉问题修复 (#2608) --- src/dialog/dialog.tsx | 8 +++++--- src/dialog/stack.ts | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/dialog/dialog.tsx b/src/dialog/dialog.tsx index f4505f557..dc79f3ea7 100644 --- a/src/dialog/dialog.tsx +++ b/src/dialog/dialog.tsx @@ -173,7 +173,9 @@ export default mixins(ActionMixin, getConfigReceiverMixins('d this.clearStyleFunc(); } // 多个dialog同时存在时使用esc关闭异常 (#1209) - this.storeUid(value); + this.$nextTick(() => { + this.storeUid(value); + }); this.addKeyboardEvent(value); if (this.isModeLess && this.draggable) { this.$nextTick(() => { @@ -238,12 +240,12 @@ export default mixins(ActionMixin, getConfigReceiverMixins('d destroySelf() { this.$el.parentNode?.removeChild?.(this.$el); }, - + // 多个dialog情况,若有些给了默认值true,出现ESC关闭不了弹窗问题解决 storeUid(flag: boolean) { if (flag) { stack.push(this.uid); } else { - stack.pop(); + stack.pop(this.uid); } }, addKeyboardEvent(status: boolean) { diff --git a/src/dialog/stack.ts b/src/dialog/stack.ts index 9d552d166..a2971acc8 100644 --- a/src/dialog/stack.ts +++ b/src/dialog/stack.ts @@ -4,8 +4,10 @@ const push = (value: number) => { data.push(value); }; -const pop = () => { - data.pop(); +const pop = (value: number) => { + if (data.length && data.includes(value)) { + data.pop(); + } }; const stack = {