Skip to content
Snippets Groups Projects
Unverified Commit fe7706e8 authored by Kyle Doherty's avatar Kyle Doherty Committed by GitHub
Browse files

ensure searchText has a value before redirecting to results (#8184)

* ensure searchText has a value before redirecting to results

* fix check
parent b1d891dc
Branches
Tags
No related merge requests found
......@@ -110,13 +110,14 @@ class SearchBar extends React.Component {
}
render() {
const { active, searchText } = this.state;
return (
<OnClickOutsideWrapper
handleDismissal={() => this.setState({ active: false })}
>
<SearchWrapper
onClick={() => this.setState({ active: true })}
active={this.state.active}
active={active}
>
<Icon name="search" ml={2} />
<SearchInput
......@@ -124,15 +125,15 @@ class SearchBar extends React.Component {
py={2}
pr={2}
pl={1}
value={this.state.searchText}
value={searchText}
placeholder="Search…"
onClick={() => this.setState({ active: true })}
onChange={e => this.setState({ searchText: e.target.value })}
onKeyPress={e => {
if (e.key === "Enter") {
if (e.key === "Enter" && (searchText || "").trim().length > 0) {
this.props.onChangeLocation({
pathname: "search",
query: { q: this.state.searchText },
query: { q: searchText },
});
}
}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment