Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions www/src/components/search-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ class SearchForm extends Component {
super()
this.state = { enabled: true, focussed: false }
this.autocompleteSelected = this.autocompleteSelected.bind(this)
this.focusSearchInput = this.focusSearchInput.bind(this)
}

/**
Expand All @@ -257,16 +256,6 @@ class SearchForm extends Component {
navigateTo(`${a.pathname}${a.hash}`)
}

focusSearchInput(e) {
if (e.key !== `s`) return

// ignore this shortcut whenever an <input> has focus
if (document.activeElement instanceof window.HTMLInputElement) return // eslint-disable-line no-undef

e.preventDefault()
this.searchInput.focus()
}

componentDidMount() {
if (
typeof window === `undefined` || // eslint-disable-line no-undef
Expand All @@ -277,9 +266,6 @@ class SearchForm extends Component {
return
}

// eslint-disable-next-line no-undef
window.addEventListener(`keydown`, this.focusSearchInput)

// eslint-disable-next-line no-undef
window.addEventListener(
`autocomplete:selected`,
Expand All @@ -297,15 +283,11 @@ class SearchForm extends Component {
openOnFocus: true,
autoselect: true,
hint: false,
keyboardShortcuts: ['s']
},
})
}

componentWillUnmount() {
// eslint-disable-next-line no-undef
window.removeEventListener(`keydown`, this.focusSearchInput)
}

render() {
const { enabled, focussed } = this.state
const { iconStyles, isHomepage } = this.props
Expand Down