Skip to content

Commit a6675b8

Browse files
111731: Remove empty arrays from query Params, since they can cause the labels to temporarily display undefined for a few milliseconds
1 parent 47f89a6 commit a6675b8

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/app/core/services/route.service.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,18 @@ describe('RouteService', () => {
201201
});
202202
});
203203

204+
it('should remove the parameter completely if only one value is defined in an array', (done: DoneFn) => {
205+
route.testParams['f.author'] = ['1282121b-5394-4689-ab93-78d537764052,authority'];
206+
service.getParamsExceptValue('f.author', '1282121b-5394-4689-ab93-78d537764052,authority').pipe(take(1)).subscribe((params: Params) => {
207+
expect(params).toEqual({
208+
'query': '',
209+
'spc.page': '1',
210+
'f.has_content_in_original_bundle': 'true,equals',
211+
});
212+
done();
213+
});
214+
});
215+
204216
it('should return all params except the applied filter even when multiple filters of the same type are selected', (done: DoneFn) => {
205217
route.testParams['f.author'] = ['1282121b-5394-4689-ab93-78d537764052,authority', '71b91a28-c280-4352-a199-bd7fc3312501,authority'];
206218
service.getParamsExceptValue('f.author', '1282121b-5394-4689-ab93-78d537764052,authority').pipe(take(1)).subscribe((params: Params) => {

src/app/core/services/route.service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ export class RouteService {
242242
delete newParams[name];
243243
} else if (Array.isArray(queryParamValues) && queryParamValues.includes(value)) {
244244
newParams[name] = (queryParamValues as string[]).filter((paramValue: string) => paramValue !== value);
245+
if (newParams[name].length === 0) {
246+
delete newParams[name];
247+
}
245248
}
246249
return newParams;
247250
}),

0 commit comments

Comments
 (0)