From fa8bdeb1574d9348ed8a9c4485bfca83e69e569c Mon Sep 17 00:00:00 2001 From: Atmire-Kristof <34308852+Atmire-Kristof@users.noreply.github.com> Date: Fri, 5 Sep 2025 23:46:44 +0200 Subject: [PATCH] Clear url parameters for entity search tabs (#2734) * 110878: Entity search - clear params on tab switch * 110878: Properly clear browse-by values when navigating * 132230: Related entity tab switching: only keep query & scope, reset page to 1 --------- Co-authored-by: Nona Luypaert --- .../browse-by-metadata/browse-by-metadata.component.ts | 2 ++ .../tabbed-related-entities-search.component.spec.ts | 10 +++++++++- .../tabbed-related-entities-search.component.ts | 4 +++- .../browse-entry-list-element.component.html | 2 +- .../date/starts-with-date.component.spec.ts | 8 ++++---- .../starts-with/starts-with-abstract.component.ts | 3 +-- .../text/starts-with-text.component.spec.ts | 4 ++-- 7 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/app/browse-by/browse-by-metadata/browse-by-metadata.component.ts b/src/app/browse-by/browse-by-metadata/browse-by-metadata.component.ts index 6b66be8eaf..4cd615dcc4 100644 --- a/src/app/browse-by/browse-by-metadata/browse-by-metadata.component.ts +++ b/src/app/browse-by/browse-by-metadata/browse-by-metadata.component.ts @@ -248,6 +248,8 @@ export class BrowseByMetadataComponent implements OnInit, OnChanges, OnDestroy { if (typeof params.startsWith === 'string') { this.startsWith = params.startsWith.trim(); + } else { + this.startsWith = ''; } if (isNotEmpty(this.value)) { diff --git a/src/app/item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.spec.ts b/src/app/item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.spec.ts index 9a00ea3e40..727b8489af 100644 --- a/src/app/item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.spec.ts +++ b/src/app/item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.spec.ts @@ -44,6 +44,12 @@ describe('TabbedRelatedEntitiesSearchComponent', () => { provide: ActivatedRoute, useValue: { queryParams: of({ tab: mockRelationType }), + snapshot: { + queryParams: { + scope: 'collection-uuid', + query: 'test', + }, + }, }, }, { provide: Router, useValue: router }, @@ -89,8 +95,10 @@ describe('TabbedRelatedEntitiesSearchComponent', () => { relativeTo: (comp as any).route, queryParams: { tab: event.nextId, + query: 'test', + scope: 'collection-uuid', + 'spc.page': 1, }, - queryParamsHandling: 'merge', }); }); }); diff --git a/src/app/item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts b/src/app/item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts index f0a8228537..8c43f43915 100644 --- a/src/app/item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts +++ b/src/app/item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts @@ -89,8 +89,10 @@ export class TabbedRelatedEntitiesSearchComponent implements OnInit { relativeTo: this.route, queryParams: { tab: event.nextId, + query: this.route.snapshot.queryParams.query, + scope: this.route.snapshot.queryParams.scope, + 'spc.page': 1, }, - queryParamsHandling: 'merge', }); } diff --git a/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.html b/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.html index 524243f23d..20be3e5562 100644 --- a/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.html +++ b/src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.html @@ -1,6 +1,6 @@
@if (linkType !== linkTypes.None) { - + {{object.value}} } diff --git a/src/app/shared/starts-with/date/starts-with-date.component.spec.ts b/src/app/shared/starts-with/date/starts-with-date.component.spec.ts index 6a48f0db22..b1db5586e9 100644 --- a/src/app/shared/starts-with/date/starts-with-date.component.spec.ts +++ b/src/app/shared/starts-with/date/starts-with-date.component.spec.ts @@ -100,7 +100,7 @@ describe('StartsWithDateComponent', () => { }); it('should add a startsWith query parameter', () => { - expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }); + expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }, undefined, { queryParamsHandling: '' }); }); it('should automatically fill in the input field', () => { @@ -122,7 +122,7 @@ describe('StartsWithDateComponent', () => { }); it('should add a startsWith query parameter', () => { - expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }); + expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }, undefined, { queryParamsHandling: '' }); }); it('should automatically fill in the input field', () => { @@ -146,7 +146,7 @@ describe('StartsWithDateComponent', () => { }); it('should add a startsWith query parameter', () => { - expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }); + expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }, undefined, { queryParamsHandling: '' }); }); it('should automatically fill in the input field', () => { @@ -171,7 +171,7 @@ describe('StartsWithDateComponent', () => { }); it('should add a startsWith query parameter', () => { - expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }); + expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }, undefined, { queryParamsHandling: '' }); }); }); diff --git a/src/app/shared/starts-with/starts-with-abstract.component.ts b/src/app/shared/starts-with/starts-with-abstract.component.ts index e2d5ca3e0f..98147175c0 100644 --- a/src/app/shared/starts-with/starts-with-abstract.component.ts +++ b/src/app/shared/starts-with/starts-with-abstract.component.ts @@ -92,11 +92,10 @@ export abstract class StartsWithAbstractComponent implements OnInit, OnDestroy { this.startsWith = undefined; } if (resetPage) { - this.paginationService.updateRoute(this.paginationId, { page: 1 }, { startsWith: this.startsWith }); + this.paginationService.updateRoute(this.paginationId, { page: 1 }, { startsWith: this.startsWith }, undefined, { queryParamsHandling: '' }); } else { void this.router.navigate([], { queryParams: Object.assign({ startsWith: this.startsWith }), - queryParamsHandling: 'merge', }); } } diff --git a/src/app/shared/starts-with/text/starts-with-text.component.spec.ts b/src/app/shared/starts-with/text/starts-with-text.component.spec.ts index c0c6996d96..a48a121786 100644 --- a/src/app/shared/starts-with/text/starts-with-text.component.spec.ts +++ b/src/app/shared/starts-with/text/starts-with-text.component.spec.ts @@ -74,8 +74,8 @@ describe('StartsWithTextComponent', () => { expect(comp.startsWith).toEqual(expectedValue); }); - it('should add a startsWith query parameter', () => { - expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }); + it('should add a startsWith query parameter and clear all others', () => { + expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }, undefined, { queryParamsHandling: '' }); }); });