Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dialog): 修复visible默认为true的情况 无法esc关闭的问题 #4178

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions src/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,26 +181,28 @@ 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(() => {
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,
},
);

Expand Down
Loading