Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/ui/public/query_bar/components/query_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ declare module '@elastic/eui' {
export const EuiOutsideClickDetector: SFC<any>;
}

import { debounce } from 'lodash';
import { debounce, uniq } from 'lodash';
import React, { Component, SFC } from 'react';
import { getFromLegacyIndexPattern } from 'ui/index_patterns/static_utils';
import { kfetch } from 'ui/kfetch';
Expand Down Expand Up @@ -242,10 +242,9 @@ export class QueryBar extends Component<Props, State> {
if (!this.persistedLog) {
return [];
}
const recentSearches = this.persistedLog.get();
const recentSearches = uniq(this.persistedLog.get().map(toUser));
const matchingRecentSearches = recentSearches.filter(recentQuery => {
const recentQueryString = typeof recentQuery === 'object' ? toUser(recentQuery) : recentQuery;
return recentQueryString.includes(query);
return recentQuery.includes(query);
});
return matchingRecentSearches.map(recentSearch => {
const text = recentSearch;
Expand Down Expand Up @@ -379,7 +378,7 @@ export class QueryBar extends Component<Props, State> {
preventDefault();
}

if (this.persistedLog) {
if (this.persistedLog && this.state.query.query.trim() !== '') {
this.persistedLog.add(this.state.query.query);
}

Expand Down