Merge pull request #276 from lbryio/trim-search-term

Trim search query
This commit is contained in:
Jeremy Kauffman 2017-06-23 09:42:31 -04:00 committed by GitHub
commit ade2788d33

View file

@ -50,7 +50,7 @@ class WunderBar extends React.PureComponent {
this._resetOnNextBlur = hasQuery; this._resetOnNextBlur = hasQuery;
this._isSearchDispatchPending = false; this._isSearchDispatchPending = false;
if (searchQuery) { if (searchQuery) {
this.props.onSearch(searchQuery); this.props.onSearch(searchQuery.trim());
} }
}, WunderBar.TYPING_TIMEOUT); // 800ms delay, tweak for faster/slower }, WunderBar.TYPING_TIMEOUT); // 800ms delay, tweak for faster/slower
} }
@ -125,12 +125,14 @@ class WunderBar extends React.PureComponent {
this._resetOnNextBlur = false; this._resetOnNextBlur = false;
clearTimeout(this._userTypingTimer); clearTimeout(this._userTypingTimer);
const value = this._input.value.trim();
try { try {
uri = lbryuri.normalize(this._input.value); uri = lbryuri.normalize(value);
this.setState({ value: uri }); this.setState({ value: uri });
} catch (error) { } catch (error) {
//then it's not a valid URL, so let's search //then it's not a valid URL, so let's search
uri = this._input.value; uri = value;
method = "onSearch"; method = "onSearch";
} }