Guard against empty and undefined index pattern arrays passed to QueryBar (#24607) (#26487)

* guard against empty and undefined index pattern arrays

* fix merge issues
This commit is contained in:
Matt Bargar 2018-11-30 17:21:46 -05:00 committed by GitHub
parent 6f864e282a
commit 01dc301d6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,7 +19,7 @@
import { IndexPattern } from 'ui/index_patterns';
import { debounce, isEqual } from 'lodash';
import { compact, debounce, isEqual } from 'lodash';
import React, { Component } from 'react';
import { getFromLegacyIndexPattern } from 'ui/index_patterns/static_utils';
import { kfetch } from 'ui/kfetch';
@ -184,7 +184,11 @@ export class QueryBar extends Component<Props, State> {
const recentSearchSuggestions = this.getRecentSearchSuggestions(query);
const autocompleteProvider = getAutocompleteProvider(language);
if (!autocompleteProvider) {
if (
!autocompleteProvider ||
!Array.isArray(this.props.indexPatterns) ||
compact(this.props.indexPatterns).length === 0
) {
return recentSearchSuggestions;
}