Skip to content

Commit

Permalink
Debounce filter value suggestion refresh (#48450) (#48698)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bargs authored Oct 22, 2019
1 parent ff8b1e9 commit a415c28
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { Component } from 'react';
import { debounce } from 'lodash';
import { Field, IndexPattern } from '../../../index_patterns';
import {
withKibana,
Expand Down Expand Up @@ -65,15 +66,15 @@ export class PhraseSuggestorUI<T extends PhraseSuggestorProps> extends Component
this.updateSuggestions(`${value}`);
};

protected async updateSuggestions(value: string = '') {
protected updateSuggestions = debounce(async (value: string = '') => {
const { indexPattern, field } = this.props as PhraseSuggestorProps;
if (!field || !this.isSuggestingValues()) {
return;
}
this.setState({ isLoading: true });
const suggestions = await this.services.data.getSuggestions(indexPattern.title, field, value);
this.setState({ suggestions, isLoading: false });
}
}, 500);
}

export const PhraseSuggestor = withKibana(PhraseSuggestorUI);

0 comments on commit a415c28

Please sign in to comment.