Skip to content

Commit

Permalink
fix(web) disallow deselecting all degrees on impact analysis view (da…
Browse files Browse the repository at this point in the history
  • Loading branch information
jayacryl authored Dec 9, 2024
1 parent 2babbe6 commit bb67af0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion datahub-web-react/src/app/search/SimpleSearchFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand Down Expand Up @@ -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);
};
Expand Down

0 comments on commit bb67af0

Please sign in to comment.