fix(a11y): search input (#51329)

This commit is contained in:
Bruce Blaser 2023-08-21 11:20:46 -07:00 committed by GitHub
parent 42ba01b914
commit 72fde26843
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -316,8 +316,7 @@ li > button.nav-link-signout:not([aria-disabled='true']):is(:hover, :focus) {
menu is collapsed. */
.universal-nav-right
#toggle-button-nav[aria-expanded='false']
+ .fcc_searchBar
.ais-SearchBox-form {
+ .fcc_searchBar {
display: none;
}

View File

@ -72,7 +72,14 @@ export class SearchBar extends Component<SearchBarProps, SearchBarState> {
}
componentDidMount(): void {
const { t } = this.props;
document.addEventListener('click', this.handleFocus);
const searchInput = document.querySelector('.ais-SearchBox-input');
if (searchInput) {
searchInput.setAttribute('aria-label', t('search.label'));
}
}
componentWillUnmount(): void {
@ -198,9 +205,6 @@ export class SearchBar extends Component<SearchBarProps, SearchBarState> {
>
<HotKeys handlers={this.keyHandlers} keyMap={this.keyMap}>
<div className='fcc_search_wrapper'>
<label className='fcc_sr_only' htmlFor='fcc_instantsearch'>
{t('search.label')}
</label>
<ObserveKeys except={['Space']}>
<div onFocus={this.handleFocus} role='textbox'>
<SearchBox