pull/3509/head
mertsincan 2023-01-09 13:06:24 +00:00
commit 2eb06ea8e5
1 changed files with 11 additions and 10 deletions

View File

@ -1,6 +1,6 @@
<template>
<Portal>
<transition name="p-confirm-popup" @enter="onEnter" @leave="onLeave" @after-leave="onAfterLeave">
<transition name="p-confirm-popup" @enter="onEnter" @after-enter="onAfterEnter" @leave="onLeave" @after-leave="onAfterLeave">
<div v-if="visible" :ref="containerRef" v-focustrap role="alertdialog" :class="containerClass" :aria-modal="visible" @click="onOverlayClick" @keydown="onOverlayKeydown" v-bind="$attrs">
<template v-if="!$slots.message">
<div class="p-confirm-popup-content">
@ -35,7 +35,9 @@ export default {
data() {
return {
visible: false,
confirmation: null
confirmation: null,
autoFocusAccept: null,
autoFocusReject: null
};
},
target: null,
@ -129,13 +131,18 @@ export default {
}
},
onEnter(el) {
this.focus();
this.autoFocusAccept = this.confirmation.defaultFocus === undefined || this.confirmation.defaultFocus === 'accept' ? true : false;
this.autoFocusReject = this.confirmation.defaultFocus === 'reject' ? true : false;
this.bindOutsideClickListener();
this.bindScrollListener();
this.bindResizeListener();
ZIndexUtils.set('overlay', el, this.$primevue.config.zIndex.overlay);
},
onAfterEnter() {
this.focus();
},
onLeave() {
this.unbindOutsideClickListener();
this.unbindScrollListener();
@ -221,7 +228,7 @@ export default {
let focusTarget = this.container.querySelector('[autofocus]');
if (focusTarget) {
focusTarget.focus();
focusTarget.focus({ preventScroll: true }); // Firefox requires preventScroll
}
},
isTargetClicked(event) {
@ -276,12 +283,6 @@ export default {
},
rejectClass() {
return ['p-confirm-popup-reject p-button-sm', this.confirmation ? this.confirmation.rejectClass || 'p-button-text' : null];
},
autoFocusAccept() {
return this.confirmation.defaultFocus === undefined || this.confirmation.defaultFocus === 'accept' ? true : false;
},
autoFocusReject() {
return this.confirmation.defaultFocus === 'reject' ? true : false;
}
},
components: {