Update searchbar to query with empty term

This commit is contained in:
Sundeep Chand 2020-07-28 12:48:52 +05:30
parent e299bf2a39
commit 1091a4e4af

View file

@ -23,25 +23,19 @@ class Searchbar extends React.Component {
});
}
handleSearchEnter = (e) => {
if (e.key === 'Enter') {
this.searchChange();
}
}
// handleSearchEnter = (e) => {
// if (e.key === 'Enter') {
// this.searchChange();
// }
// }
searchChange = () => {
if (this.state.searchValue.trim().length === 0) return;
this.props.setSearchTerm(this.state.searchValue.trim());
};
handleSearchChange = (e) => {
if (e.target.value === '') {
// Manually reset the searchValue if the search field becomes empty.
this.handleResetSearch();
return;
}
this.setState({ searchValue: e.target.value }, () => {
this.throttledSearchChange(this.state.searchValue);
this.throttledSearchChange(this.state.searchValue.trim());
});
}
@ -58,7 +52,7 @@ class Searchbar extends React.Component {
value={searchValue}
placeholder={this.props.searchLabel}
onChange={this.handleSearchChange}
onKeyUp={this.handleSearchEnter}
// onKeyUp={this.handleSearchEnter}
/>
<button
className="searchbar__clear-button"