From 6377da8291adb2abb17e69db1e5eafb90de7ef0b Mon Sep 17 00:00:00 2001 From: Yishu See Date: Thu, 27 Oct 2016 02:57:57 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20issue=20#2758.=20Press=20Escape=20after?= =?UTF-8?q?=20a=20finished=20search=20to=20get=20back=20to=20=E2=80=A6=20(?= =?UTF-8?q?#2939)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix issue #2758. Press Escape after a finished search to get back to Inbox Use a keydown event when search bar is in focus to capture escape key press * fix(search): Convert to ES2016 --- internal_packages/thread-search/lib/search-bar.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal_packages/thread-search/lib/search-bar.jsx b/internal_packages/thread-search/lib/search-bar.jsx index 2157f599c..88e5001df 100644 --- a/internal_packages/thread-search/lib/search-bar.jsx +++ b/internal_packages/thread-search/lib/search-bar.jsx @@ -90,6 +90,12 @@ export default class SearchBar extends React.Component { }, 150); } + _onKeyDown = (event) => { + if (event.keyCode === 27) { + this._onClearAndBlur(); + } + } + _doSearch = () => { SearchActions.querySubmitted(this.state.query); } @@ -142,6 +148,7 @@ export default class SearchBar extends React.Component { onChange={this._onValueChange} onFocus={this._onFocus} onBlur={this._onBlur} + onKeyDown={this._onKeyDown} />, loupeImg,