Merge pull request #6142 from clemvnt/fix/dialog-focus

Dialog: Cherry pick 're-focus original element on close' fix to v4
pull/6171/head
Tuğçe Küçükoğlu 2024-08-01 15:22:32 +03:00 committed by GitHub
commit e70a844997
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View File

@ -78,7 +78,8 @@ export default {
visible: false, visible: false,
confirmation: null, confirmation: null,
autoFocusAccept: null, autoFocusAccept: null,
autoFocusReject: null autoFocusReject: null,
target: null
}; };
}, },
target: null, target: null,
@ -175,6 +176,8 @@ export default {
this.autoFocusAccept = this.confirmation.defaultFocus === undefined || this.confirmation.defaultFocus === 'accept' ? true : false; this.autoFocusAccept = this.confirmation.defaultFocus === undefined || this.confirmation.defaultFocus === 'accept' ? true : false;
this.autoFocusReject = this.confirmation.defaultFocus === 'reject' ? true : false; this.autoFocusReject = this.confirmation.defaultFocus === 'reject' ? true : false;
this.target = document.activeElement;
this.bindOutsideClickListener(); this.bindOutsideClickListener();
this.bindScrollListener(); this.bindScrollListener();
this.bindResizeListener(); this.bindResizeListener();
@ -188,6 +191,9 @@ export default {
this.autoFocusAccept = null; this.autoFocusAccept = null;
this.autoFocusReject = null; this.autoFocusReject = null;
DomHandler.focus(this.target);
this.target = null;
this.unbindOutsideClickListener(); this.unbindOutsideClickListener();
this.unbindScrollListener(); this.unbindScrollListener();
this.unbindResizeListener(); this.unbindResizeListener();

View File

@ -91,7 +91,8 @@ export default {
containerVisible: this.visible, containerVisible: this.visible,
maximized: false, maximized: false,
focusableMax: null, focusableMax: null,
focusableClose: null focusableClose: null,
target: null,
}; };
}, },
watch: { watch: {
@ -147,6 +148,7 @@ export default {
}, },
onEnter() { onEnter() {
this.$emit('show'); this.$emit('show');
this.target = document.activeElement;
this.focus(); this.focus();
this.enableDocumentSettings(); this.enableDocumentSettings();
this.bindGlobalListeners(); this.bindGlobalListeners();
@ -162,6 +164,8 @@ export default {
}, },
onLeave() { onLeave() {
this.$emit('hide'); this.$emit('hide');
DomHandler.focus(this.target);
this.target = null;
this.focusableClose = null; this.focusableClose = null;
this.focusableMax = null; this.focusableMax = null;
}, },