Skip to content

Commit

Permalink
smooth out autofocus code
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Jun 21, 2023
1 parent 50cb308 commit f4678a1
Showing 1 changed file with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,11 @@ export const SearchBar: FC<SearchBarProps> = ({
singleSelection={true}
renderOption={(option) => euiSelectableTemplateSitewideRenderOptions(option, searchTerm)}
searchProps={{
autoFocus: chromeStyle === 'project',
value: searchValue,
onInput: (e: React.UIEvent<HTMLInputElement>) => setSearchValue(e.currentTarget.value),
'data-test-subj': 'nav-search-input',
inputRef: (input) => {
setSearchRef(input);
if (chromeStyle === 'project' && input) {
// while the input ref is in flight, we set focus on it
// to autofocus the input when it appears
input.focus();
}
},
inputRef: setSearchRef,
compressed: true,
'aria-label': i18nStrings.placeholderText,
placeholder: i18nStrings.placeholderText,
Expand Down

0 comments on commit f4678a1

Please sign in to comment.