Skip to content

Commit 3e1a909

Browse files
author
Luke Barnard
committed
Just use the onKeyDown of the <input>
1 parent 41cd238 commit 3e1a909

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

‎src/components/structures/SearchBox.js‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ module.exports = React.createClass({
4040

4141
componentDidMount: function() {
4242
this.dispatcherRef = dis.register(this.onAction);
43-
document.addEventListener('keydown', this._onKeyDown);
4443
},
4544

4645
componentWillUnmount: function() {
4746
dis.unregister(this.dispatcherRef);
48-
document.removeEventListener('keydown', this._onKeyDown);
4947
},
5048

5149
onAction: function(payload) {
@@ -91,8 +89,6 @@ module.exports = React.createClass({
9189
},
9290

9391
_onKeyDown: function(ev) {
94-
// Only do anything when the key event target is the search input
95-
if(ev.target !== this.refs.search) return;
9692
switch (ev.keyCode) {
9793
case KeyCode.ESCAPE:
9894
this._clearSearch();
@@ -150,6 +146,7 @@ module.exports = React.createClass({
150146
className="mx_SearchBox_search"
151147
value={ this.state.searchTerm }
152148
onChange={ this.onChange }
149+
onKeyDown={ this._onKeyDown }
153150
placeholder={ _t('Filter room names') }
154151
/>
155152
];

0 commit comments

Comments
 (0)