Fix closable dialog focus
When opening a closable dialog, the focus goes to the close button. ```html <button aria-label="close" type="button" class="p-dialog-titlebar-icon p-dialog-titlebar-close p-link">...</button> ``` This button should not be focusedpull/310/head
parent
4a861c2577
commit
dfa41f905b
|
@ -122,9 +122,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
focus() {
|
focus() {
|
||||||
let focusable = DomHandler.findSingle(this.$refs.dialog, 'input,button');
|
let focusableElements = DomHandler.getFocusableElements(this.$refs.dialog);
|
||||||
if (focusable) {
|
if (focusableElements && focusableElements.length > 0) {
|
||||||
focusable.focus();
|
focusableElements[0].focus();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
maximize() {
|
maximize() {
|
||||||
|
|
|
@ -402,7 +402,7 @@ export default class DomHandler {
|
||||||
|
|
||||||
static getFocusableElements(element) {
|
static getFocusableElements(element) {
|
||||||
let focusableElements = DomHandler.find(element, `button:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]),
|
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]),
|
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]),
|
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])`
|
[contenteditable]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])`
|
||||||
|
|
Loading…
Reference in New Issue