Fix autofocus behavior for radio button and check box groups #2629
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.
What are you trying to accomplish?
This PR fixes autofocus behavior for radio button and check box groups. According to Primer's form guidelines, "the first invalid input should be focused and scrolled into the viewport". There are two problems with the current implementation:
<div>
element and should instead be attached to the wrapping<fieldset>
element. This is causing screen readers to skip announcing the validation message.autofocus
attribute is not present on any element.This PR fixes both issues. See this Slack discussion (internal only) for additional details.
Integration
No changes necessary in production.
Risk Assessment
What approach did you choose and why?
See the linked Slack discussion above.
Accessibility
This PR does not fix an axe scan violation, but it does address two accessibility audit issues, see (internal only):
Merge checklist