From 3e1a909b1d2ae7e6bea24514723c214dd2d845ef Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 12 Jul 2017 17:46:27 +0100 Subject: [PATCH] Just use the onKeyDown of the --- src/components/structures/SearchBox.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/structures/SearchBox.js b/src/components/structures/SearchBox.js index e35d1e48..0499e601 100644 --- a/src/components/structures/SearchBox.js +++ b/src/components/structures/SearchBox.js @@ -40,12 +40,10 @@ module.exports = React.createClass({ componentDidMount: function() { this.dispatcherRef = dis.register(this.onAction); - document.addEventListener('keydown', this._onKeyDown); }, componentWillUnmount: function() { dis.unregister(this.dispatcherRef); - document.removeEventListener('keydown', this._onKeyDown); }, onAction: function(payload) { @@ -91,8 +89,6 @@ module.exports = React.createClass({ }, _onKeyDown: function(ev) { - // Only do anything when the key event target is the search input - if(ev.target !== this.refs.search) return; switch (ev.keyCode) { case KeyCode.ESCAPE: this._clearSearch(); @@ -150,6 +146,7 @@ module.exports = React.createClass({ className="mx_SearchBox_search" value={ this.state.searchTerm } onChange={ this.onChange } + onKeyDown={ this._onKeyDown } placeholder={ _t('Filter room names') } /> ];