Skip to content

Commit

Permalink
[Infra UI] Auto focus search bar when page mounts for accessibility (e…
Browse files Browse the repository at this point in the history
…lastic#31758)

* Fixes elastic#28154 - Auto focus search bar when page mounts

* Adding check
  • Loading branch information
simianhacker committed Feb 25, 2019
1 parent 7489374 commit 2f93495
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ export class AutocompleteField extends React.Component<
);
}

public componentDidMount() {
if (this.inputElement) {
this.inputElement.focus();
}
}

public componentDidUpdate(prevProps: AutocompleteFieldProps, prevState: AutocompleteFieldState) {
const hasNewValue = prevProps.value !== this.props.value;
const hasNewSuggestions = prevProps.suggestions !== this.props.suggestions;
Expand Down

0 comments on commit 2f93495

Please sign in to comment.