From 86f58e37cae0d50cc751b53a894feccd1adc15e0 Mon Sep 17 00:00:00 2001 From: jayacryl <159848059+jayacryl@users.noreply.github.com> Date: Mon, 9 Dec 2024 12:03:48 -0500 Subject: [PATCH] fix(web) disallow deselecting all degrees on impact analysis view --- .../src/app/search/SimpleSearchFilters.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/datahub-web-react/src/app/search/SimpleSearchFilters.tsx b/datahub-web-react/src/app/search/SimpleSearchFilters.tsx index 416b04403723f5..877efb55fcf828 100644 --- a/datahub-web-react/src/app/search/SimpleSearchFilters.tsx +++ b/datahub-web-react/src/app/search/SimpleSearchFilters.tsx @@ -4,7 +4,12 @@ import { FacetFilterInput, FacetMetadata } from '../../types.generated'; import { FilterScenarioType } from './filters/render/types'; import { useFilterRendererRegistry } from './filters/render/useFilterRenderer'; import { SimpleSearchFilter } from './SimpleSearchFilter'; -import { ENTITY_FILTER_NAME, ENTITY_INDEX_FILTER_NAME, LEGACY_ENTITY_FILTER_NAME } from './utils/constants'; +import { + DEGREE_FILTER_NAME, + ENTITY_FILTER_NAME, + ENTITY_INDEX_FILTER_NAME, + LEGACY_ENTITY_FILTER_NAME, +} from './utils/constants'; const TOP_FILTERS = ['degree', ENTITY_FILTER_NAME, 'platform', 'tags', 'glossaryTerms', 'domains', 'owners']; @@ -43,6 +48,15 @@ export const SimpleSearchFilters = ({ facets, selectedFilters, onFilterSelect, l : filter, ) .filter((filter) => filter.field !== field || !(filter.values?.length === 0)); + + // Do not let user unselect all degree filters + if (field === DEGREE_FILTER_NAME && !selected) { + const hasDegreeFilter = newFilters.find((filter) => filter.field === DEGREE_FILTER_NAME); + if (!hasDegreeFilter) { + return; + } + } + setCachedProps({ ...cachedProps, selectedFilters: newFilters }); onFilterSelect(newFilters); };