-
Notifications
You must be signed in to change notification settings - Fork 389
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
fix(docsearch-react): add aria-hidden to SearchIcon and add accessible label to SearchBox input #2193
fix(docsearch-react): add aria-hidden to SearchIcon and add accessible label to SearchBox input #2193
Conversation
👷 Deploy request for docsearch pending review.Visit the deploys page to approve it
|
@@ -34,20 +34,8 @@ function noResultSearch(_queries: any, _requestOptions?: any): Promise<any> { | |||
} | |||
|
|||
describe('api', () => { | |||
let container: HTMLDivElement; |
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.
It doesn't look like we're using container anywhere besides in the before/afterEach? So I removed them.
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.
awesome, thanks a lot for taking the time to improve DocSearch
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.
Thank you @hbuchel!
Could you please slightly increase the bundle size thresholds?
{
"files": [
{
"path": "packages/docsearch-css/dist/style.css",
- "maxSize": "3 kB"
+ "maxSize": "3.25 kB"
},
{
"path": "packages/docsearch-react/dist/umd/index.js",
- "maxSize": "22.80 kB"
+ "maxSize": "23 kB"
},
{
"path": "packages/docsearch-js/dist/umd/index.js",
- "maxSize": "30.70 kB"
+ "maxSize": "31 kB"
}
]
}
Updated, thanks! |
There are 2 main changes in this PR:
aria-hidden
to the SearchIcon so it can be hidden to assistive tech users. The unlabelled SVG can be accessed by screenreaders and can also get caught by automated accessibility audits. Since it's decorative, we can safely hide it witharia-hidden="true"
in<SearchBox />
and<SearchButton />
searchInputLabel
, to the search form's input. Currently the<input />
is associated with a<label>
that does not have an accessible label, only an unlabelled SVG as a child element. This PR adds accessibly hidden text within the<label>
. I opted to use visually hidden text (using CSS to hide the text but still make it available for assistive tech users) for the label text because it's generally a better practice than reaching foraria-label
.Additionally, this PR:
searchInputLabel