Trim search query

This commit is contained in:
6ea86b96 2017-06-23 13:21:37 +07:00
parent f1f0c15548
commit 717e6c12bf
No known key found for this signature in database
GPG key ID: B282D183E4931E8F

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";
} }