1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

refs #247 Add fixed blur handler

This commit is contained in:
asmsuechan
2017-01-17 10:33:32 +09:00
parent ebea01cecf
commit 2af2399971

View File

@@ -48,21 +48,30 @@ class FinderMain extends React.Component {
}
this.focusHandler = (e) => this.handleWindowFocus(e)
this.blurHandler = (e) => this.handleWindowBlur(e)
}
componentDidMount () {
this.refs.search.focus()
window.addEventListener('focus', this.focusHandler)
window.addEventListener('blur', this.blurHandler)
}
componentWillUnmount () {
window.removeEventListener('focus', this.focusHandler)
window.removeEventListener('blur', this.blurHandler)
}
handleWindowFocus (e) {
this.refs.search.focus()
}
handleWindowBlur (e) {
this.setState({
search: '',
})
}
handleKeyDown (e) {
this.refs.search.focus()
if (e.keyCode === 9) {