Skip to content

Commit bf24baf

Browse files
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 <[email protected]>
1 parent c48c4ad commit bf24baf

File tree

7 files changed

+22
-11
lines changed

7 files changed

+22
-11
lines changed

src/app/browse-by/browse-by-metadata/browse-by-metadata.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ export class BrowseByMetadataComponent implements OnInit, OnChanges, OnDestroy {
248248

249249
if (typeof params.startsWith === 'string') {
250250
this.startsWith = params.startsWith.trim();
251+
} else {
252+
this.startsWith = '';
251253
}
252254

253255
if (isNotEmpty(this.value)) {

src/app/item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ describe('TabbedRelatedEntitiesSearchComponent', () => {
4444
provide: ActivatedRoute,
4545
useValue: {
4646
queryParams: of({ tab: mockRelationType }),
47+
snapshot: {
48+
queryParams: {
49+
scope: 'collection-uuid',
50+
query: 'test',
51+
},
52+
},
4753
},
4854
},
4955
{ provide: Router, useValue: router },
@@ -89,8 +95,10 @@ describe('TabbedRelatedEntitiesSearchComponent', () => {
8995
relativeTo: (comp as any).route,
9096
queryParams: {
9197
tab: event.nextId,
98+
query: 'test',
99+
scope: 'collection-uuid',
100+
'spc.page': 1,
92101
},
93-
queryParamsHandling: 'merge',
94102
});
95103
});
96104
});

src/app/item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,10 @@ export class TabbedRelatedEntitiesSearchComponent implements OnInit {
8989
relativeTo: this.route,
9090
queryParams: {
9191
tab: event.nextId,
92+
query: this.route.snapshot.queryParams.query,
93+
scope: this.route.snapshot.queryParams.scope,
94+
'spc.page': 1,
9295
},
93-
queryParamsHandling: 'merge',
9496
});
9597
}
9698

src/app/shared/object-list/browse-entry-list-element/browse-entry-list-element.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="d-flex flex-row">
22
@if (linkType !== linkTypes.None) {
3-
<a [target]="(linkType === linkTypes.ExternalLink) ? '_blank' : '_self'" [attr.rel]="(linkType === linkTypes.ExternalLink) ? 'noopener noreferrer' : null" [routerLink]="[]" [queryParams]="queryParams$ | async" [queryParamsHandling]="'merge'" class="lead" role="link" tabindex="0">
3+
<a [target]="(linkType === linkTypes.ExternalLink) ? '_blank' : '_self'" [attr.rel]="(linkType === linkTypes.ExternalLink) ? 'noopener noreferrer' : null" [routerLink]="[]" [queryParams]="queryParams$ | async" class="lead" role="link" tabindex="0">
44
{{object.value}}
55
</a>
66
}

src/app/shared/starts-with/date/starts-with-date.component.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ describe('StartsWithDateComponent', () => {
100100
});
101101

102102
it('should add a startsWith query parameter', () => {
103-
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue });
103+
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }, undefined, { queryParamsHandling: '' });
104104
});
105105

106106
it('should automatically fill in the input field', () => {
@@ -122,7 +122,7 @@ describe('StartsWithDateComponent', () => {
122122
});
123123

124124
it('should add a startsWith query parameter', () => {
125-
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue });
125+
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }, undefined, { queryParamsHandling: '' });
126126
});
127127

128128
it('should automatically fill in the input field', () => {
@@ -146,7 +146,7 @@ describe('StartsWithDateComponent', () => {
146146
});
147147

148148
it('should add a startsWith query parameter', () => {
149-
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue });
149+
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }, undefined, { queryParamsHandling: '' });
150150
});
151151

152152
it('should automatically fill in the input field', () => {
@@ -171,7 +171,7 @@ describe('StartsWithDateComponent', () => {
171171
});
172172

173173
it('should add a startsWith query parameter', () => {
174-
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue });
174+
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }, undefined, { queryParamsHandling: '' });
175175
});
176176
});
177177

src/app/shared/starts-with/starts-with-abstract.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,10 @@ export abstract class StartsWithAbstractComponent implements OnInit, OnDestroy {
9292
this.startsWith = undefined;
9393
}
9494
if (resetPage) {
95-
this.paginationService.updateRoute(this.paginationId, { page: 1 }, { startsWith: this.startsWith });
95+
this.paginationService.updateRoute(this.paginationId, { page: 1 }, { startsWith: this.startsWith }, undefined, { queryParamsHandling: '' });
9696
} else {
9797
void this.router.navigate([], {
9898
queryParams: Object.assign({ startsWith: this.startsWith }),
99-
queryParamsHandling: 'merge',
10099
});
101100
}
102101
}

src/app/shared/starts-with/text/starts-with-text.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ describe('StartsWithTextComponent', () => {
7474
expect(comp.startsWith).toEqual(expectedValue);
7575
});
7676

77-
it('should add a startsWith query parameter', () => {
78-
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue });
77+
it('should add a startsWith query parameter and clear all others', () => {
78+
expect(paginationService.updateRoute).toHaveBeenCalledWith('page-id', { page: 1 }, { startsWith: expectedValue }, undefined, { queryParamsHandling: '' });
7979
});
8080
});
8181

0 commit comments

Comments
 (0)