Improve .form-group accessibility #1028
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.
This is a first attempt to make our
.form-group
component more accessible.Problem
In our docs we suggest using a "definition list" (
<dl>
) for the.form-group
component. We even "bake it in" and make it a requirement by using selectors likedl.form-group > dd
. The problem is that it can be "too noisy" for screen readers when there is a<dt>
with just one<dd>
.Fix
This PR replaces...
<dl class="form-group">
👉<div class="form-group">
<dt>
👉<div class="form-group-header">
<dd>
👉<div class="form-group-body">
in the docs.
Before
After
For now, the CSS selectors e.g
dl.form-group > dd
are unchanged. We'll have to wait to deprecate them until the next major release. Also, first we'd have to replace all the markup everywhere on dotcom.Alternative
We might not even need those "wrapper" elements and could reduce the markup down to:
It would probably require some more testing and maybe refactoring on dotcom? 🤔
/cc @primer/ds-core