From 2af2399971282494a4db850b54b020bc9c90a04b Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Tue, 17 Jan 2017 10:33:32 +0900 Subject: [PATCH] refs #247 Add fixed blur handler --- browser/finder/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/browser/finder/index.js b/browser/finder/index.js index 72701f74..1120fc8e 100644 --- a/browser/finder/index.js +++ b/browser/finder/index.js @@ -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) {