Store search state in URL

This commit is contained in:
David Kaltschmidt
2016-05-11 18:08:59 +02:00
parent d5eea2549d
commit cfb5161cd7
4 changed files with 23 additions and 17 deletions
+4 -3
View File
@@ -74,15 +74,16 @@ class Search extends React.Component {
render() {
const { inputId = 'search', nodes, pinnedSearches, searchFocused,
searchNodeMatches, topologiesLoaded } = this.props;
searchNodeMatches, searchQuery, topologiesLoaded } = this.props;
const disabled = this.props.isTopologyEmpty || !topologiesLoaded;
const matchCount = searchNodeMatches
.reduce((count, topologyMatches) => count + topologyMatches.size, 0);
const showPinnedSearches = pinnedSearches.size > 0;
const value = this.state.value || searchQuery || '';
const classNames = cx('search', {
'search-pinned': showPinnedSearches,
'search-matched': matchCount,
'search-filled': this.state.value,
'search-filled': value,
'search-focused': searchFocused,
'search-disabled': disabled
});
@@ -101,7 +102,7 @@ class Search extends React.Component {
.map(query => <SearchItem query={query} key={query} />)}
</span>}
<input className="search-input-field" type="text" id={inputId}
value={this.state.value} onChange={this.handleChange}
value={value} onChange={this.handleChange}
onBlur={this.handleBlur} onFocus={this.handleFocus}
disabled={disabled} />
</div>