fix: fix the unexpected joggle state when `dialog` component non-fixed (#6161)

pull/6273/head
王子凌 2024-08-22 15:02:01 +08:00 committed by GitHub
parent bdb20ab244
commit f97a108a31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -1,7 +1,7 @@
<template>
<Portal :appendTo="appendTo">
<div v-if="containerVisible" :ref="maskRef" :class="cx('mask')" :style="sx('mask', true, { position, modal })" @mousedown="onMaskMouseDown" @mouseup="onMaskMouseUp" v-bind="ptm('mask')">
<transition name="p-dialog" @before-enter="onBeforeEnter" @enter="onEnter" @before-leave="onBeforeLeave" @leave="onLeave" @after-leave="onAfterLeave" appear v-bind="ptm('transition')">
<transition name="p-dialog" @before-enter="onBeforeEnter" @enter="onEnter" @after-enter="onAfterEnter" @before-leave="onBeforeLeave" @leave="onLeave" @after-leave="onAfterLeave" appear v-bind="ptm('transition')">
<div v-if="visible" :ref="containerRef" v-focustrap="{ disabled: !modal }" :class="cx('root')" :style="sx('root')" role="dialog" :aria-labelledby="ariaLabelledById" :aria-modal="modal" v-bind="ptmi('root')">
<slot v-if="$slots.container" name="container" :closeCallback="close" :maximizeCallback="(event) => maximize(event)"></slot>
<template v-else>
@ -149,7 +149,6 @@ export default {
onEnter() {
this.$emit('show');
this.target = document.activeElement;
this.focus();
this.enableDocumentSettings();
this.bindGlobalListeners();
@ -157,6 +156,9 @@ export default {
ZIndex.set('modal', this.mask, this.baseZIndex + this.$primevue.config.zIndex.modal);
}
},
onAfterEnter() {
this.focus();
},
onBeforeLeave() {
if (this.modal) {
!this.isUnstyled && addClass(this.mask, 'p-overlay-mask-leave');