From 8924b2c92cdf0a261acd6fbbc157a03d30998620 Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Wed, 13 Apr 2022 09:45:37 +0200 Subject: [PATCH] 90768: Prevent empty filters from being added --- .../search-facet-filter.component.ts | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/app/shared/search/search-filters/search-filter/search-facet-filter/search-facet-filter.component.ts b/src/app/shared/search/search-filters/search-filter/search-facet-filter/search-facet-filter.component.ts index 2892fd5240..4f226add54 100644 --- a/src/app/shared/search/search-filters/search-filter/search-facet-filter/search-facet-filter.component.ts +++ b/src/app/shared/search/search-filters/search-filter/search-facet-filter/search-facet-filter.component.ts @@ -230,27 +230,29 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy { } /** - * Submits a new active custom value to the filter from the input field + * Submits a new active custom value to the filter from the input field when the input field isn't empty. * @param data The string from the input field */ onSubmit(data: any) { - this.selectedValues$.pipe(take(1)).subscribe((selectedValues) => { - if (isNotEmpty(data)) { - this.router.navigate(this.getSearchLinkParts(), { - queryParams: - { - [this.filterConfig.paramName]: [ - ...selectedValues.map((facet) => this.getFacetValue(facet)), - data - ] - }, - queryParamsHandling: 'merge' - }); - this.filter = ''; + if (data.match(new RegExp(`^.+,(equals|query|authority)$`))) { + this.selectedValues$.pipe(take(1)).subscribe((selectedValues) => { + if (isNotEmpty(data)) { + this.router.navigate(this.getSearchLinkParts(), { + queryParams: + { + [this.filterConfig.paramName]: [ + ...selectedValues.map((facet) => this.getFacetValue(facet)), + data + ] + }, + queryParamsHandling: 'merge' + }); + this.filter = ''; + } + this.filterSearchResults = observableOf([]); } - this.filterSearchResults = observableOf([]); - } - ); + ); + } } /**