@@ -68,6 +68,7 @@ module.exports = React.createClass({
6868 this . filterString = null ;
6969 this . filterTimeout = null ;
7070 this . scrollPanel = null ;
71+ this . searchBox = null ;
7172
7273 // dis.dispatch({
7374 // action: 'ui_opacity',
@@ -212,9 +213,7 @@ module.exports = React.createClass({
212213 return this . getMoreRooms ( ) ;
213214 } ,
214215
215- onFilterChange : function ( ev ) {
216- const alias = ev . target . value ;
217-
216+ onFilterChange : function ( alias ) {
218217 this . filterString = alias || null ;
219218
220219 // don't send the request for a little bit,
@@ -230,10 +229,22 @@ module.exports = React.createClass({
230229 } , 300 ) ;
231230 } ,
232231
233- onFilterKeyUp : function ( ev ) {
234- if ( ev . key == "Enter" ) {
235- this . showRoomAlias ( ev . target . value ) ;
232+ onFilterChange : function ( ) {
233+ this . filterString = null ;
234+
235+ if ( this . filterTimeout ) {
236+ clearTimeout ( this . filterTimeout ) ;
236237 }
238+ // update immediately
239+ this . refreshRoomList ( ) ;
240+ } ,
241+
242+ onJoinClick : function ( alias ) {
243+ this . showRoomAlias ( alias ) ;
244+ } ,
245+
246+ collectSearchBox : function ( e ) {
247+ this . searchBox = e ;
237248 } ,
238249
239250 showRoomAlias : function ( alias ) {
@@ -393,13 +404,15 @@ module.exports = React.createClass({
393404
394405 const SimpleRoomHeader = sdk . getComponent ( 'rooms.SimpleRoomHeader' ) ;
395406 const NetworkDropdown = sdk . getComponent ( 'directory.NetworkDropdown' ) ;
407+ const DirectorySearchBox = sdk . getComponent ( 'elements.DirectorySearchBox' ) ;
396408 return (
397409 < div className = "mx_RoomDirectory" >
398410 < SimpleRoomHeader title = "Directory" />
399411 < div className = "mx_RoomDirectory_list" >
400412 < 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 }
413+ < DirectorySearchBox
414+ className = "mx_RoomDirectory_searchbox" ref = { this . collectSearchBox }
415+ onChange = { this . onFilterChange } onClear = { this . onFilterClear } onJoinClick = { this . onJoinClick }
403416 />
404417 < NetworkDropdown config = { this . props . config } onNetworkChange = { this . onNetworkChange } />
405418 </ div >
0 commit comments