From d94f1a481670ea70f0ea6598bd38631c9481a5af Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Thu, 16 Nov 2023 08:51:43 +0200 Subject: [PATCH] Address PR comment for histogram --- .../public/layout/hooks/use_lens_suggestions.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/plugins/unified_histogram/public/layout/hooks/use_lens_suggestions.ts b/src/plugins/unified_histogram/public/layout/hooks/use_lens_suggestions.ts index 5cd28db5cdc704..b3f66767e85a88 100644 --- a/src/plugins/unified_histogram/public/layout/hooks/use_lens_suggestions.ts +++ b/src/plugins/unified_histogram/public/layout/hooks/use_lens_suggestions.ts @@ -61,7 +61,7 @@ export const useLensSuggestions = ({ const [allSuggestions, setAllSuggestions] = useState(suggestions.allSuggestions); const currentSuggestion = originalSuggestion ?? suggestions.firstSuggestion; const suggestionDeps = useRef(getSuggestionDeps({ dataView, query, columns })); - const histogramQuery = useRef(''); + const histogramQuery = useRef(); const histogramSuggestion = useMemo(() => { if ( !currentSuggestion && @@ -111,13 +111,13 @@ export const useLensSuggestions = ({ }; const sug = lensSuggestionsApi(context, dataView, ['lnsDatatable']) ?? []; if (sug.length) { - histogramQuery.current = esqlQuery; + histogramQuery.current = { esql: esqlQuery }; return sug[0]; } - histogramQuery.current = ''; + histogramQuery.current = undefined; return undefined; } - histogramQuery.current = ''; + histogramQuery.current = undefined; return undefined; }, [currentSuggestion, dataView, query, timeRange, data, lensSuggestionsApi]); @@ -144,7 +144,7 @@ export const useLensSuggestions = ({ currentSuggestion: histogramSuggestion ?? currentSuggestion, suggestionUnsupported: !currentSuggestion && !histogramSuggestion && isPlainRecord, isOnHistogramMode: Boolean(histogramSuggestion), - histogramQuery: histogramQuery.current ? { esql: histogramQuery.current } : undefined, + histogramQuery: histogramQuery.current ? histogramQuery.current : undefined, }; };