UX: unconditionally focus modals (#13179)

Previously auto focus would only work on modals that include buttons or
inputs.

To avoid a situation where information modals such as keyboard shortcuts
do not get focus, simply focus on the close button as a fallback.
This commit is contained in:
Sam 2021-05-27 11:45:12 +10:00 committed by GitHub
parent 34c5df2700
commit 489535e5c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -141,6 +141,10 @@ export default Component.extend({
focusTarget = this.element.querySelector(
".modal-body input, .modal-body button, .modal-footer input, .modal-footer button"
);
if (!focusTarget) {
focusTarget = this.element.querySelector(".modal-header button");
}
}
if (focusTarget) {
afterTransition(() => focusTarget.focus());