Oops, onChange doesn't catch the enter key

This commit is contained in:
David Baker 2016-09-16 20:56:14 +01:00
parent d0618c4f49
commit 53fd3f52fa

View File

@ -215,22 +215,24 @@ module.exports = React.createClass({
onFilterChange: function(ev) { onFilterChange: function(ev) {
const alias = ev.target.value; const alias = ev.target.value;
if (ev.key == "Enter") { this.filterString = alias || null;
this.showRoomAlias(alias);
} else {
this.filterString = alias || null;
// don't send the request for a little bit, // don't send the request for a little bit,
// no point hammering the server with a // no point hammering the server with a
// request for every keystroke, let the // request for every keystroke, let the
// user finish typing. // user finish typing.
if (this.filterTimeout) { if (this.filterTimeout) {
clearTimeout(this.filterTimeout); clearTimeout(this.filterTimeout);
} }
this.filterTimeout = setTimeout(() => { this.filterTimeout = setTimeout(() => {
this.filterTimeout = null; this.filterTimeout = null;
this.refreshRoomList(); this.refreshRoomList();
}, 300); }, 300);
},
onFilterKeyUp: function(ev) {
if (ev.key == "Enter") {
this.showRoomAlias(ev.target.value);
} }
}, },
@ -397,7 +399,7 @@ module.exports = React.createClass({
<div className="mx_RoomDirectory_list"> <div className="mx_RoomDirectory_list">
<div className="mx_RoomDirectory_listheader"> <div className="mx_RoomDirectory_listheader">
<input type="text" placeholder="Find a room by keyword or room ID (#foo:matrix.org)" <input type="text" placeholder="Find a room by keyword or room ID (#foo:matrix.org)"
className="mx_RoomDirectory_input" size="64" onChange={this.onFilterChange} className="mx_RoomDirectory_input" size="64" onChange={this.onFilterChange} onKeyUp={this.onFilterKeyUp}
/> />
<NetworkDropdown config={this.props.config} onNetworkChange={this.onNetworkChange} /> <NetworkDropdown config={this.props.config} onNetworkChange={this.onNetworkChange} />
</div> </div>