-
-
Notifications
You must be signed in to change notification settings - Fork 78.7k
docs: hide placeholder select options from assistive tech #42739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,7 +69,7 @@ Custom feedback styles apply custom colors, borders, focus styles, and backgroun | |
| <div class="col-md-3"> | ||
| <label for="validationCustom04" class="form-label">State</label> | ||
| <select class="form-select" id="validationCustom04" required> | ||
| <option selected disabled value="">Choose...</option> | ||
| <option selected disabled value="" aria-hidden="true">Choose...</option> | ||
| <option>...</option> | ||
|
Comment on lines
69
to
73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In these validation examples the placeholder option is both
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is the stronger concern, since the placeholder is also the current value here and hiding it could leave the control announcing nothing on focus. I can revert the validation.mdx changes so aria-hidden is only used where the placeholder is not the selected value, if that is the direction the team wants. |
||
| </select> | ||
| <div class="invalid-feedback"> | ||
|
|
@@ -130,7 +130,7 @@ While these feedback styles cannot be styled with CSS, you can still customize t | |
| <div class="col-md-3"> | ||
| <label for="validationDefault04" class="form-label">State</label> | ||
| <select class="form-select" id="validationDefault04" required> | ||
| <option selected disabled value="">Choose...</option> | ||
| <option selected disabled value="" aria-hidden="true">Choose...</option> | ||
| <option>...</option> | ||
| </select> | ||
| </div> | ||
|
|
@@ -194,7 +194,7 @@ To fix [issues with border radius](https://github.com/twbs/bootstrap/issues/2511 | |
| <div class="col-md-3"> | ||
| <label for="validationServer04" class="form-label">State</label> | ||
| <select class="form-select is-invalid" id="validationServer04" aria-describedby="validationServer04Feedback" required> | ||
| <option selected disabled value="">Choose...</option> | ||
| <option selected disabled value="" aria-hidden="true">Choose...</option> | ||
| <option>...</option> | ||
| </select> | ||
| <div id="validationServer04Feedback" class="invalid-feedback"> | ||
|
|
@@ -316,7 +316,7 @@ If your form layout allows it, you can swap the `.{valid|invalid}-feedback` clas | |
| <div class="col-md-3 position-relative"> | ||
| <label for="validationTooltip04" class="form-label">State</label> | ||
| <select class="form-select" id="validationTooltip04" required> | ||
| <option selected disabled value="">Choose...</option> | ||
| <option selected disabled value="" aria-hidden="true">Choose...</option> | ||
| <option>...</option> | ||
| </select> | ||
| <div class="invalid-tooltip"> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aria-hiddenon<option>has inconsistent AT supportScreen readers on Windows (NVDA, JAWS) traditionally access native
<select>elements through OS-level accessibility APIs (IAccessible2/UIA) rather than the ARIA accessibility tree. The degree to which those APIs propagatearia-hiddenon individual<option>children varies by browser/AT pairing. There's real risk that the attribute is silently ignored by major screen readers in practice, leaving the documentation teaching a pattern that may not behave as described. A more broadly supported technique for a non-selectable placeholder isdisabled hidden value=""on the<option>, which signals non-selectability at the HTML level rather than relying on ARIA propagation through a native OS widget. This applies across every changed file in this PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point on the uneven AT support. The intent here is only to stop the placeholder from being read out as a real choice in the options list; visual rendering is unchanged. If the team prefers, I can scope this down to the select.mdx examples only, or drop it entirely in favor of documenting the disabled+hidden placeholder pattern instead. Happy to go either way.