Skip to content

Commit dca62d6

Browse files
111731: Fixed double requests being sent when selecting a range with the absolute min/max (1950/current year)
This was caused because the search labels updated the query parameters, even when they were already updated by the facets
1 parent 10dfedd commit dca62d6

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/app/shared/search/search-filters/search-filter/search-facet-filter-options/search-facet-range-option/search-facet-range-option.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ describe('SearchFacetRangeOptionComponent', () => {
119119
};
120120
(comp as any).updateChangeParams();
121121
expect(comp.changeQueryParams).toEqual({
122-
[mockFilterConfig.paramName + RANGE_FILTER_MIN_SUFFIX]: ['50'],
123-
[mockFilterConfig.paramName + RANGE_FILTER_MAX_SUFFIX]: ['60'],
122+
[mockFilterConfig.paramName + RANGE_FILTER_MIN_SUFFIX]: [50],
123+
[mockFilterConfig.paramName + RANGE_FILTER_MAX_SUFFIX]: [60],
124124
['page-id.page']: 1
125125
});
126126
});

src/app/shared/search/search-filters/search-filter/search-facet-filter-options/search-facet-range-option/search-facet-range-option.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ export class SearchFacetRangeOptionComponent implements OnInit, OnDestroy {
104104
*/
105105
private updateChangeParams(): void {
106106
const parts = this.filterValue.value.split(rangeDelimiter);
107-
const min = parts.length > 1 ? parts[0].trim() : this.filterValue.value;
108-
const max = parts.length > 1 ? parts[1].trim() : this.filterValue.value;
107+
const min = parts.length > 1 ? Number(parts[0].trim()) : this.filterValue.value;
108+
const max = parts.length > 1 ? Number(parts[1].trim()) : this.filterValue.value;
109109
const page = this.paginationService.getPageParam(this.searchConfigService.paginationID);
110110
this.changeQueryParams = {
111111
[this.filterConfig.paramName + RANGE_FILTER_MIN_SUFFIX]: [min],
112-
[this.filterConfig.paramName + RANGE_FILTER_MAX_SUFFIX]: [max],
112+
[this.filterConfig.paramName + RANGE_FILTER_MAX_SUFFIX]: max === this.absoluteMax ? null : [max],
113113
[page]: 1
114114
};
115115
}

src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class SearchRangeFilterComponent extends SearchFacetFilterComponent imple
6969
/**
7070
* The current range of the filter
7171
*/
72-
range;
72+
range: [number | undefined, number | undefined];
7373

7474
/**
7575
* Subscription to unsubscribe from
@@ -107,13 +107,13 @@ export class SearchRangeFilterComponent extends SearchFacetFilterComponent imple
107107
this.max = moment(this.filterConfig.maxValue, dateFormats).year() || this.max;
108108
const iniMin = this.route.getQueryParameterValue(this.filterConfig.paramName + RANGE_FILTER_MIN_SUFFIX).pipe(startWith(undefined));
109109
const iniMax = this.route.getQueryParameterValue(this.filterConfig.paramName + RANGE_FILTER_MAX_SUFFIX).pipe(startWith(undefined));
110-
this.sub = observableCombineLatest(iniMin, iniMax).pipe(
111-
map(([min, max]) => {
112-
const minimum = hasValue(min) ? min : this.min;
113-
const maximum = hasValue(max) ? max : this.max;
110+
this.sub = observableCombineLatest([iniMin, iniMax]).pipe(
111+
map(([min, max]: [string, string]) => {
112+
const minimum = hasValue(min) ? Number(min) : this.min;
113+
const maximum = hasValue(max) ? Number(max) : this.max;
114114
return [minimum, maximum];
115115
})
116-
).subscribe((minmax) => this.range = minmax);
116+
).subscribe((minmax: [number, number]) => this.range = minmax);
117117
}
118118

119119
setAppliedFilter(allFacetValues: FacetValues[]): void {
@@ -139,7 +139,7 @@ export class SearchRangeFilterComponent extends SearchFacetFilterComponent imple
139139

140140
const newMin = this.range[0] !== this.min ? [this.range[0]] : null;
141141
const newMax = this.range[1] !== this.max ? [this.range[1]] : null;
142-
this.router.navigate(this.getSearchLinkParts(), {
142+
void this.router.navigate(this.getSearchLinkParts(), {
143143
queryParams:
144144
{
145145
[this.filterConfig.paramName + RANGE_FILTER_MIN_SUFFIX]: newMin,

0 commit comments

Comments
 (0)