90768: Already selected filters were still displayed in the clickable suggestions

This commit is contained in:
Alexandre Vryghem
2022-04-14 10:28:18 +02:00
parent e3172fd6e8
commit 8e5bfc023e
3 changed files with 4 additions and 4 deletions

View File

@@ -162,7 +162,7 @@ describe('SearchFacetSelectedOptionComponent', () => {
comp.removeQueryParams = {};
(comp as any).updateRemoveParams(selectedValues);
expect(comp.removeQueryParams).toEqual({
[mockFilterConfig.paramName]: [value1],
[mockFilterConfig.paramName]: [`${value1},equals`],
['page-id.page']: 1
});
});

View File

@@ -37,7 +37,7 @@ describe('Search Utils', () => {
});
it('should retrieve the correct value from the search href', () => {
expect(getFacetValueForType(facetValueWithSearchHref, searchFilterConfig)).toEqual('Value with search href,operator');
expect(getFacetValueForType(facetValueWithSearchHref, searchFilterConfig)).toEqual('Value with search href,equals');
});
it('should retrieve the correct value from the Facet', () => {

View File

@@ -9,11 +9,11 @@ import { isNotEmpty } from '../empty.util';
* @param searchFilterConfig
*/
export function getFacetValueForType(facetValue: FacetValue, searchFilterConfig: SearchFilterConfig): string {
const regex = new RegExp(`[?|&]${escapeRegExp(searchFilterConfig.paramName)}=(${escapeRegExp(facetValue.value)}[^&]*)`, 'g');
const regex = new RegExp(`[?|&]${escapeRegExp(encodeURIComponent(searchFilterConfig.paramName))}=(${escapeRegExp(encodeURIComponent(facetValue.value))}[^&]*)`, 'g');
if (isNotEmpty(facetValue._links)) {
const values = regex.exec(facetValue._links.search.href);
if (isNotEmpty(values)) {
return values[1];
return decodeURIComponent(values[1]);
}
}
if (facetValue.authorityKey) {