@@ -98,6 +98,8 @@ module.exports = React.createClass({
9898 } ,
9999
100100 getMoreRooms : function ( ) {
101+ if ( ! MatrixClientPeg . get ( ) ) return q ( ) ;
102+
101103 const my_filter_string = this . filterString ;
102104 const opts = { limit : 20 } ;
103105 if ( this . nextBatch ) opts . since = this . nextBatch ;
@@ -212,9 +214,7 @@ module.exports = React.createClass({
212214 return this . getMoreRooms ( ) ;
213215 } ,
214216
215- onFilterChange : function ( ev ) {
216- const alias = ev . target . value ;
217-
217+ onFilterChange : function ( alias ) {
218218 this . filterString = alias || null ;
219219
220220 // don't send the request for a little bit,
@@ -230,10 +230,18 @@ module.exports = React.createClass({
230230 } , 300 ) ;
231231 } ,
232232
233- onFilterKeyUp : function ( ev ) {
234- if ( ev . key == "Enter" ) {
235- this . showRoomAlias ( ev . target . value ) ;
233+ onFilterClear : function ( ) {
234+ this . filterString = null ;
235+
236+ if ( this . filterTimeout ) {
237+ clearTimeout ( this . filterTimeout ) ;
236238 }
239+ // update immediately
240+ this . refreshRoomList ( ) ;
241+ } ,
242+
243+ onJoinClick : function ( alias ) {
244+ this . showRoomAlias ( alias ) ;
237245 } ,
238246
239247 showRoomAlias : function ( alias ) {
@@ -393,13 +401,15 @@ module.exports = React.createClass({
393401
394402 const SimpleRoomHeader = sdk . getComponent ( 'rooms.SimpleRoomHeader' ) ;
395403 const NetworkDropdown = sdk . getComponent ( 'directory.NetworkDropdown' ) ;
404+ const DirectorySearchBox = sdk . getComponent ( 'elements.DirectorySearchBox' ) ;
396405 return (
397406 < div className = "mx_RoomDirectory" >
398407 < SimpleRoomHeader title = "Directory" />
399408 < div className = "mx_RoomDirectory_list" >
400409 < div className = "mx_RoomDirectory_listheader" >
401- < input type = "text" placeholder = "Find a room by keyword or room ID (#foo:matrix.org)"
402- className = "mx_RoomDirectory_input" size = "64" onChange = { this . onFilterChange } onKeyUp = { this . onFilterKeyUp }
410+ < DirectorySearchBox
411+ className = "mx_RoomDirectory_searchbox"
412+ onChange = { this . onFilterChange } onClear = { this . onFilterClear } onJoinClick = { this . onJoinClick }
403413 />
404414 < NetworkDropdown config = { this . props . config } onNetworkChange = { this . onNetworkChange } />
405415 </ div >
0 commit comments