From ad6645ab565f052139fb64a3c2d34ad7b7b2b323 Mon Sep 17 00:00:00 2001 From: Matt Bargar Date: Fri, 18 Oct 2019 16:27:18 -0400 Subject: [PATCH] Debounce filter value suggestion refresh (#48450) --- .../filter/filter_bar/filter_editor/phrase_suggestor.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/legacy/core_plugins/data/public/filter/filter_bar/filter_editor/phrase_suggestor.tsx b/src/legacy/core_plugins/data/public/filter/filter_bar/filter_editor/phrase_suggestor.tsx index 9ef5f546c0be0..426c21c99ccdb 100644 --- a/src/legacy/core_plugins/data/public/filter/filter_bar/filter_editor/phrase_suggestor.tsx +++ b/src/legacy/core_plugins/data/public/filter/filter_bar/filter_editor/phrase_suggestor.tsx @@ -18,6 +18,7 @@ */ import { Component } from 'react'; +import { debounce } from 'lodash'; import { Field, IndexPattern } from '../../../index_patterns'; import { withKibana, @@ -65,7 +66,7 @@ export class PhraseSuggestorUI 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; @@ -73,7 +74,7 @@ export class PhraseSuggestorUI extends Component 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);