From 7c851a97b061e024ec4d9a4041234f22f72afc54 Mon Sep 17 00:00:00 2001 From: "algerkc@qq.com" Date: Wed, 8 May 2024 11:25:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(dialog):=20=E4=BF=AE=E5=A4=8Dvisible?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E4=B8=BAtrue=E7=9A=84=E6=83=85=E5=86=B5=20?= =?UTF-8?q?=E6=97=A0=E6=B3=95esc=E5=85=B3=E9=97=AD=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closed #4153 --- src/dialog/dialog.tsx | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/dialog/dialog.tsx b/src/dialog/dialog.tsx index 3d245e70cc..fa2d9181a6 100644 --- a/src/dialog/dialog.tsx +++ b/src/dialog/dialog.tsx @@ -181,26 +181,30 @@ export default defineComponent({ watch( () => props.visible, (value) => { - if (value) { - if ((isModal.value && !props.showInAttachedElement) || isFullScreen.value) { - if (props.preventScrollThrough) { - document.body.appendChild(styleEl.value); - } - - nextTick(() => { - if (mousePosition && dialogEle.value) { - dialogEle.value.style.transformOrigin = `${mousePosition.x - dialogEle.value.offsetLeft}px ${ - mousePosition.y - dialogEle.value.offsetTop - }px`; + nextTick(() => { + if (value) { + if ((isModal.value && !props.showInAttachedElement) || isFullScreen.value) { + if (props.preventScrollThrough) { + document.body.appendChild(styleEl.value); } - }); + () => { + if (mousePosition && dialogEle.value) { + dialogEle.value.style.transformOrigin = `${mousePosition.x - dialogEle.value.offsetLeft}px ${ + mousePosition.y - dialogEle.value.offsetTop + }px`; + } + }; + } + // 清除鼠标焦点 避免entry事件多次触发(按钮弹出弹窗 不移除焦点 立即按Entry按键 会造成弹窗关闭再弹出) + (document.activeElement as HTMLElement)?.blur(); + } else { + clearStyleFunc(); } - // 清除鼠标焦点 避免entry事件多次触发(按钮弹出弹窗 不移除焦点 立即按Entry按键 会造成弹窗关闭再弹出) - (document.activeElement as HTMLElement)?.blur(); - } else { - clearStyleFunc(); - } - addKeyboardEvent(value); + addKeyboardEvent(value); + }); + }, + { + immediate: true, }, ); From 2e93ebebfbf2dc57d6bc7fa9934b81478a010be5 Mon Sep 17 00:00:00 2001 From: "algerkc@qq.com" Date: Wed, 8 May 2024 17:00:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?style(dialog):=20=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=E6=97=A0=E7=94=A8=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dialog/dialog.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/dialog/dialog.tsx b/src/dialog/dialog.tsx index fa2d9181a6..66f54fc8cb 100644 --- a/src/dialog/dialog.tsx +++ b/src/dialog/dialog.tsx @@ -187,13 +187,11 @@ export default defineComponent({ if (props.preventScrollThrough) { document.body.appendChild(styleEl.value); } - () => { - if (mousePosition && dialogEle.value) { - dialogEle.value.style.transformOrigin = `${mousePosition.x - dialogEle.value.offsetLeft}px ${ - mousePosition.y - dialogEle.value.offsetTop - }px`; - } - }; + if (mousePosition && dialogEle.value) { + dialogEle.value.style.transformOrigin = `${mousePosition.x - dialogEle.value.offsetLeft}px ${ + mousePosition.y - dialogEle.value.offsetTop + }px`; + } } // 清除鼠标焦点 避免entry事件多次触发(按钮弹出弹窗 不移除焦点 立即按Entry按键 会造成弹窗关闭再弹出) (document.activeElement as HTMLElement)?.blur();