From 462a0176d666ec7015d3780f0d9edb6b9758274b Mon Sep 17 00:00:00 2001 From: Chris Collins Date: Wed, 2 Nov 2022 18:56:48 -0400 Subject: [PATCH] fix(ui) Fix filters in embedded list search component --- .../styled/search/EmbeddedListSearchSection.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/datahub-web-react/src/app/entity/shared/components/styled/search/EmbeddedListSearchSection.tsx b/datahub-web-react/src/app/entity/shared/components/styled/search/EmbeddedListSearchSection.tsx index b4fa2ecddd4b6d..98c6875b2ec52a 100644 --- a/datahub-web-react/src/app/entity/shared/components/styled/search/EmbeddedListSearchSection.tsx +++ b/datahub-web-react/src/app/entity/shared/components/styled/search/EmbeddedListSearchSection.tsx @@ -10,6 +10,18 @@ import { useEntityQueryParams } from '../../../containers/profile/utils'; import { EmbeddedListSearch } from './EmbeddedListSearch'; import { UnionType } from '../../../../../search/utils/constants'; +const FILTER = 'filter'; + +function getParamsWithoutFilters(params: QueryString.ParsedQuery) { + const paramsCopy = { ...params }; + Object.keys(paramsCopy).forEach((key) => { + if (key.startsWith(FILTER)) { + delete paramsCopy[key]; + } + }); + return paramsCopy; +} + type Props = { emptySearchQuery?: string | null; fixedFilter?: FacetFilterInput | null; @@ -43,7 +55,8 @@ export const EmbeddedListSearchSection = ({ const entityQueryParams = useEntityQueryParams(); const params = QueryString.parse(location.search, { arrayFormat: 'comma' }); - const baseParams = { ...params, ...entityQueryParams }; + const paramsWithoutFilters = getParamsWithoutFilters(params); + const baseParams = { ...entityQueryParams, ...paramsWithoutFilters }; const query: string = params?.query as string; const page: number = params.page && Number(params.page as string) > 0 ? Number(params.page as string) : 1; const unionType: UnionType = Number(params.unionType as any as UnionType) || UnionType.AND;