chore: updates page load focus management #4740
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary | Résumé
Fixes an issue where on a "page" load an AT user may first have an input focussed (perhaps by an AT or *) and a prompt about typing in the text field. Then our code would focus the first heading. So the user would think they could start typing but unexpectedly be on a heading.
The fix updates the focus element function to first check for a visible input element and focus that. If none are available then fallback to a passed in selector, probably a heading, if none is passed or the previous fails, just try to focus the main heading (h1). If there is no H1, then we have bigger problems :)
Test
Open a form with groups (pages). One of the pages should have two or more form controls (input, textarea, select). When the page that is a groups page loads, the first form control should be focussed. Your cursor should be in the first input. (or on another page without an input on the first heading)
Peter can test on Windows + Edge + Jaws.