Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Code] apply repo search scope right away in search page #34029

Merged
merged 1 commit into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions x-pack/plugins/code/public/components/main/search_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export class CodeSearchBar extends React.Component<Props> {
appName="code"
disableAutoFocus={true}
suggestionProviders={this.suggestionProviders}
enableSubmitWhenOptionsChanged={false}
onSearchScopeChanged={this.props.onSearchScopeChanged}
ref={instance => {
if (instance) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -373,6 +374,15 @@ export class CodeQueryBar extends Component<Props, State> {
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export class SearchBar extends React.PureComponent<Props> {
appName="code"
suggestionProviders={suggestionProviders}
onSearchScopeChanged={this.props.onSearchScopeChanged}
enableSubmitWhenOptionsChanged={true}
ref={instance => {
if (instance) {
// @ts-ignore
Expand Down