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

fix(ui) Fix filters in embedded list search component #6350

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>) {
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;
Expand Down Expand Up @@ -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;
Expand Down