Merge pull request #310 from ajacob/fix-dialog-focus

Fix closable dialog focus
pull/345/head
Cagatay Civici 2020-05-27 15:50:05 +03:00 committed by GitHub
commit d8e2223e17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -122,9 +122,9 @@ export default {
}
},
focus() {
let focusable = DomHandler.findSingle(this.$refs.dialog, 'input,button');
if (focusable) {
focusable.focus();
let focusableElements = DomHandler.getFocusableElements(this.$refs.dialog);
if (focusableElements && focusableElements.length > 0) {
focusableElements[0].focus();
}
},
maximize() {

View File

@ -402,7 +402,7 @@ export default class DomHandler {
static getFocusableElements(element) {
let focusableElements = DomHandler.find(element, `button:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]),
[href][clientHeight][clientWidth]:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]),
[href][clientHeight][clientWidth]:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]):not([aria-label = "close"]),
input:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]), select:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]),
textarea:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]), [tabIndex]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]),
[contenteditable]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])`