Skip to content

Commit

Permalink
Trim la query de l'autocomplete avant d'appeler le service
Browse files Browse the repository at this point in the history
  • Loading branch information
JabX committed Nov 23, 2017
1 parent 750b66f commit deabebb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "focus4",
"version": "8.3.1",
"version": "8.3.4",
"description": "Focus v4 (Typescript + MobX)",
"main": "index.js",
"repository": {
Expand Down
14 changes: 8 additions & 6 deletions src/components/autocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ export class Autocomplete extends React.Component<AutocompleteProps, void> {
* @param query Le champ texte.
*/
async search(query: string) {
this.isLoading = true;
const result = await this.props.querySearcher(query);
runInAction(() => {
this.values.replace(result && result.data && result.data.reduce((acc, next) => ({...acc, [next.key]: next.label}), {}) || {});
this.isLoading = false;
});
if (query && query.trim().length) {
this.isLoading = true;
const result = await this.props.querySearcher(query.trim());
runInAction(() => {
this.values.replace(result && result.data && result.data.reduce((acc, next) => ({...acc, [next.key]: next.label}), {}) || {});
this.isLoading = false;
});
}
}

@debounce(200)
Expand Down

0 comments on commit deabebb

Please sign in to comment.