diff --git a/src/components/searchbar.jsx b/src/components/searchbar.jsx index f786a32..567e058 100644 --- a/src/components/searchbar.jsx +++ b/src/components/searchbar.jsx @@ -8,6 +8,13 @@ class Searchbar extends React.Component { constructor(props) { super(props); this.handleChange = this.handleChange.bind(this); + this.searchBarRef = React.createRef(); + this.handleFocus = this.handleFocus.bind(this); + document.addEventListener('keypress', this.handleFocus); + } + + handleFocus() { + this.searchBarRef.current.focus(); } handleChange(event) { @@ -16,11 +23,19 @@ class Searchbar extends React.Component { } render() { + /* eslint-disable jsx-a11y/no-autofocus */ + /* eslint-disable no-trailing-spaces */ const { search, searchbarFixed } = this.props; return (
- +