diff --git a/packages/primevue/src/confirmpopup/ConfirmPopup.vue b/packages/primevue/src/confirmpopup/ConfirmPopup.vue index 42341d442..d66a8d21f 100644 --- a/packages/primevue/src/confirmpopup/ConfirmPopup.vue +++ b/packages/primevue/src/confirmpopup/ConfirmPopup.vue @@ -78,7 +78,8 @@ export default { visible: false, confirmation: null, autoFocusAccept: null, - autoFocusReject: null + autoFocusReject: null, + target: null }; }, target: null, @@ -175,6 +176,8 @@ export default { this.autoFocusAccept = this.confirmation.defaultFocus === undefined || this.confirmation.defaultFocus === 'accept' ? true : false; this.autoFocusReject = this.confirmation.defaultFocus === 'reject' ? true : false; + this.target = document.activeElement; + this.bindOutsideClickListener(); this.bindScrollListener(); this.bindResizeListener(); @@ -188,6 +191,9 @@ export default { this.autoFocusAccept = null; this.autoFocusReject = null; + DomHandler.focus(this.target); + this.target = null; + this.unbindOutsideClickListener(); this.unbindScrollListener(); this.unbindResizeListener(); diff --git a/packages/primevue/src/dialog/Dialog.vue b/packages/primevue/src/dialog/Dialog.vue index 361d1db91..3fc8bb04b 100755 --- a/packages/primevue/src/dialog/Dialog.vue +++ b/packages/primevue/src/dialog/Dialog.vue @@ -91,7 +91,8 @@ export default { containerVisible: this.visible, maximized: false, focusableMax: null, - focusableClose: null + focusableClose: null, + target: null, }; }, watch: { @@ -146,6 +147,7 @@ export default { }, onEnter() { this.$emit('show'); + this.target = document.activeElement; this.focus(); this.enableDocumentSettings(); this.bindGlobalListeners(); @@ -161,6 +163,8 @@ export default { }, onLeave() { this.$emit('hide'); + DomHandler.focus(this.target); + this.target = null; this.focusableClose = null; this.focusableMax = null; },