You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support more meaningful options for dialog autoFocus #22678
AccessibilityThis issue is related to accessibility (a11y)P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentfeatureLabel used to distinguish feature request from other issues
Currently, the autoFocus option of MatDialogConfig is a boolean, with the values meaning:
false - default value, focused the role="dialog" element
true - focuses the first tabbable element inside the dialog
This API is kind of confusing, since the dialog automatically focuses something regardless of what you do, so autoFocus: false doesn't really make sense.
Instead, we should change autoFocus to accept these values:
dialog - focus the role="dialog" element
first-tabbable - focus the first tabbable element
first-header - focus the first header (h1 - h6) element in the dialog. It's still an open question whether this should force tabIndex = -1.
A CSS selector- arbitrary CSS selector, the dialog would focus the first matching element (vis querySelector). Again an open question if this should force tabIndex = -1.
I'll throw a vote in for forcing the element to be focusable. I feel like forgetting to add tabindex will otherwise be a super common gotcha and result in bug reports that these values aren't working as expected.
The logic could be something like:
If tabindex is specified, do nothing.
Else, set tabindex to -1, and add self-removing event listeners to remove the tabindex once the element is blurred or mousedown-ed. You don't want to keep the element focusable because it will mess with a user setting the sequential focus starting point via "click to move focus" (https://googlechrome.github.io/samples/focus-navigation-start-point/).
The logic to "force-focus" an element and revert it back to normal afterward could be pulled out into a common helper function.
AccessibilityThis issue is related to accessibility (a11y)P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentfeatureLabel used to distinguish feature request from other issues
Activity
zelliott commentedon May 12, 2021
I might call it
first-headinginstead offirst-header(https://html.spec.whatwg.org/multipage/sections.html#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements) (wouldn't want it to be confused with<header>).I'll throw a vote in for forcing the element to be focusable. I feel like forgetting to add
tabindexwill otherwise be a super common gotcha and result in bug reports that these values aren't working as expected.The logic could be something like:
tabindexis specified, do nothing.tabindexto -1, and add self-removing event listeners to remove thetabindexonce the element is blurred or mousedown-ed. You don't want to keep the element focusable because it will mess with a user setting the sequential focus starting point via "click to move focus" (https://googlechrome.github.io/samples/focus-navigation-start-point/).The logic to "force-focus" an element and revert it back to normal afterward could be pulled out into a common helper function.
feat(multiple): add options to autoFocus field for dialogs
feat(multiple): add options to autoFocus field for dialogs
feat(multiple): add options to autoFocus field for dialogs
feat(multiple): add options to autoFocus field for dialogs
feat(multiple): add options to autoFocus field for dialogs
feat(multiple): add options to autoFocus field for dialogs
feat(multiple): add options to autoFocus field for dialogs
feat(multiple): add options to autoFocus field for dialogs
feat(multiple): add options to autoFocus field for dialogs
feat(multiple): add options to autoFocus field for dialogs
angular-automatic-lock-bot commentedon Aug 30, 2021
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
feat(multiple): add options to autoFocus field for dialogs (angular#2…