diff --git a/x-pack/plugins/code/public/components/main/search_bar.tsx b/x-pack/plugins/code/public/components/main/search_bar.tsx index e2aee8b227587..4de5eafa42155 100644 --- a/x-pack/plugins/code/public/components/main/search_bar.tsx +++ b/x-pack/plugins/code/public/components/main/search_bar.tsx @@ -100,6 +100,7 @@ export class CodeSearchBar extends React.Component { appName="code" disableAutoFocus={true} suggestionProviders={this.suggestionProviders} + enableSubmitWhenOptionsChanged={false} onSearchScopeChanged={this.props.onSearchScopeChanged} ref={instance => { if (instance) { diff --git a/x-pack/plugins/code/public/components/query_bar/components/query_bar.tsx b/x-pack/plugins/code/public/components/query_bar/components/query_bar.tsx index 922b6fac4bee8..a3698d0c75111 100644 --- a/x-pack/plugins/code/public/components/query_bar/components/query_bar.tsx +++ b/x-pack/plugins/code/public/components/query_bar/components/query_bar.tsx @@ -46,6 +46,7 @@ interface Props { suggestionProviders: SuggestionsProvider[]; repositorySearch: (p: { query: string }) => void; saveSearchOptions: (searchOptions: ISearchOptions) => void; + enableSubmitWhenOptionsChanged: boolean; onSearchScopeChanged: (s: SearchScope) => void; repoSearchResults: any[]; searchLoading: boolean; @@ -373,6 +374,15 @@ export class CodeQueryBar extends Component { if (prevProps.query !== this.props.query) { this.updateSuggestions(); } + + // When search options (e.g. repository scopes) change, + // submit the search query again to refresh the search result. + if ( + this.props.enableSubmitWhenOptionsChanged && + !_.isEqual(prevProps.searchOptions, this.props.searchOptions) + ) { + this.onSubmit(); + } } public componentWillUnmount() { diff --git a/x-pack/plugins/code/public/components/search_page/search_bar.tsx b/x-pack/plugins/code/public/components/search_page/search_bar.tsx index 5348a36d2204f..bc3c8d1c477d4 100644 --- a/x-pack/plugins/code/public/components/search_page/search_bar.tsx +++ b/x-pack/plugins/code/public/components/search_page/search_bar.tsx @@ -105,6 +105,7 @@ export class SearchBar extends React.PureComponent { appName="code" suggestionProviders={suggestionProviders} onSearchScopeChanged={this.props.onSearchScopeChanged} + enableSubmitWhenOptionsChanged={true} ref={instance => { if (instance) { // @ts-ignore