From d512e25ccaf828acfb1593459be7b9ceb414d4b6 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sun, 17 Apr 2016 00:28:33 +0100 Subject: [PATCH] persist search filter over being hidden --- src/components/structures/SearchBox.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/components/structures/SearchBox.js b/src/components/structures/SearchBox.js index 8c98859e1d..a49f845ea4 100644 --- a/src/components/structures/SearchBox.js +++ b/src/components/structures/SearchBox.js @@ -29,11 +29,21 @@ module.exports = React.createClass({ onSearch: React.PropTypes.func, }, - onChange: new rate_limited_func( + getInitialState: function() { + return { + searchTerm: "", + }; + }, + + onChange: function() { + if (!this.refs.search) return; + this.setState({ searchTerm: this.refs.search.value }); + this.onSearch(); + }, + + onSearch: new rate_limited_func( function() { - if (this.refs.search) { - this.props.onSearch(this.refs.search.value); - } + this.props.onSearch(this.refs.search.value); }, 100 ), @@ -81,6 +91,7 @@ module.exports = React.createClass({ type="text" ref="search" className="mx_SearchBox_search" + value={ this.state.searchTerm } onChange={ this.onChange } placeholder="Search room names" />