Encode automplete search string and don't autocomplete for empty query
This commit is contained in:
parent
055a476d2f
commit
bb9bde1c19
1 changed files with 3 additions and 1 deletions
|
@ -45,7 +45,7 @@ export const getSearchSuggestions = (value: string) => (dispatch: Dispatch, getS
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch(`${CONNECTION_STRING}autocomplete?s=${searchValue}`)
|
fetch(`${CONNECTION_STRING}autocomplete?s=${encodeURIComponent(searchValue)}`)
|
||||||
.then(handleFetchResponse)
|
.then(handleFetchResponse)
|
||||||
.then(apiSuggestions => {
|
.then(apiSuggestions => {
|
||||||
dispatch({
|
dispatch({
|
||||||
|
@ -72,6 +72,8 @@ export const doUpdateSearchQuery = (query: string, shouldSkipSuggestions: ?boole
|
||||||
data: { query },
|
data: { query },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (!query) return;
|
||||||
|
|
||||||
// Don't fetch new suggestions if the user just added a space
|
// Don't fetch new suggestions if the user just added a space
|
||||||
if (!query.endsWith(' ') || !shouldSkipSuggestions) {
|
if (!query.endsWith(' ') || !shouldSkipSuggestions) {
|
||||||
throttledSearchSuggestions(dispatch, query);
|
throttledSearchSuggestions(dispatch, query);
|
||||||
|
|
Loading…
Reference in a new issue