Skip to content

Commit

Permalink
feat: Add flag to hide/display the autocomplete query for search bar (#…
Browse files Browse the repository at this point in the history
…9104)

Co-authored-by: John Joyce <[email protected]>
  • Loading branch information
kushagra-apptware and jjoyce0510 authored Oct 27, 2023
1 parent e02b909 commit 4d2c009
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions datahub-web-react/src/app/home/HomePageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ export const HomePageHeader = () => {
viewsEnabled={viewsEnabled}
combineSiblings
showQuickFilters
showViewAllResults
/>
{searchResultsToShow && searchResultsToShow.length > 0 && (
<SuggestionsContainer>
Expand Down
6 changes: 4 additions & 2 deletions datahub-web-react/src/app/search/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ interface Props {
setIsSearchBarFocused?: (isSearchBarFocused: boolean) => void;
onFocus?: () => void;
onBlur?: () => void;
showViewAllResults?: boolean;
}

const defaultProps = {
Expand Down Expand Up @@ -146,6 +147,7 @@ export const SearchBar = ({
setIsSearchBarFocused,
onFocus,
onBlur,
showViewAllResults = false,
}: Props) => {
const history = useHistory();
const [searchQuery, setSearchQuery] = useState<string | undefined>(initialQuery);
Expand Down Expand Up @@ -203,7 +205,7 @@ export const SearchBar = ({
const { quickFilters, selectedQuickFilter, setSelectedQuickFilter } = useQuickFiltersContext();

const autoCompleteQueryOptions = useMemo(() => {
if (effectiveQuery === '') return [];
if (effectiveQuery === '' || !showViewAllResults) return [];

return [
{
Expand All @@ -212,7 +214,7 @@ export const SearchBar = ({
type: EXACT_AUTOCOMPLETE_OPTION_TYPE,
},
];
}, [effectiveQuery]);
}, [effectiveQuery, showViewAllResults]);

const autoCompleteEntityOptions = useMemo(() => {
return suggestions.map((suggestion: AutoCompleteResultForEntity) => {
Expand Down
1 change: 1 addition & 0 deletions datahub-web-react/src/app/search/SearchHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export const SearchHeader = ({
combineSiblings
fixAutoComplete
showQuickFilters
showViewAllResults
/>
</LogoSearchContainer>
<NavGroup>
Expand Down

0 comments on commit 4d2c009

Please sign in to comment.