diff --git a/src/app/components/files/files.component.spec.ts b/src/app/components/files/files.component.spec.ts index bb499fb6e..d2c1e0e08 100644 --- a/src/app/components/files/files.component.spec.ts +++ b/src/app/components/files/files.component.spec.ts @@ -241,6 +241,13 @@ describe('FilesComponent', () => { expect(router.navigate).toHaveBeenCalledWith(['personal-files', 'favourites', node.id]); }); + it('should remove the header filters param on click of folders', () => { + router.url = '/personal-files?name=abc'; + component.navigate(node.id); + + expect(router.navigate).toHaveBeenCalledWith(['personal-files', node.id]); + }); + it('should navigates to node when id provided', () => { router.url = '/personal-files'; component.navigate(node.id); diff --git a/src/app/components/files/files.component.ts b/src/app/components/files/files.component.ts index 5ebe3870d..370b4b748 100644 --- a/src/app/components/files/files.component.ts +++ b/src/app/components/files/files.component.ts @@ -124,18 +124,19 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { navigate(nodeId: string = null) { const uuidRegEx = /[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-4[0-9A-Za-z]{3}-[89ABab][0-9A-Za-z]{3}-[0-9A-Za-z]{12}/gi; - let urlToNavigate; + let urlToNavigate: string[]; + const urlWithoutParams = this.router.url.split('?')[0]; - if (this.router.url.match(uuidRegEx)) { + if (urlWithoutParams.match(uuidRegEx)) { if (nodeId && !this.isRootNode(nodeId)) { - urlToNavigate = this.router.url.replace(uuidRegEx, nodeId).split('/'); + urlToNavigate = urlWithoutParams.replace(uuidRegEx, nodeId).split('/'); } else { - urlToNavigate = this.router.url.replace(uuidRegEx, '').split('/'); + urlToNavigate = urlWithoutParams.replace(uuidRegEx, '').split('/'); urlToNavigate.pop(); } urlToNavigate.shift(); } else { - urlToNavigate = this.router.url.split('/'); + urlToNavigate = urlWithoutParams.split('/'); if (nodeId && !this.isRootNode(nodeId)) { urlToNavigate.push(nodeId); } @@ -296,6 +297,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { this.showHeader = ShowHeaderMode.Always; this.navigateToFilter(activeFilters); } else { + this.router.navigate(['.'], { relativeTo: this.route }); this.showHeader = ShowHeaderMode.Data; this.onAllFilterCleared(); } diff --git a/src/app/components/viewer/viewer.component.ts b/src/app/components/viewer/viewer.component.ts index 9782e22f3..c80568b4d 100644 --- a/src/app/components/viewer/viewer.component.ts +++ b/src/app/components/viewer/viewer.component.ts @@ -151,7 +151,7 @@ export class AppViewerComponent implements OnInit, OnDestroy { }); this.route.queryParams.subscribe((params) => { - this.navigationPath = params.path; + this.navigationPath = params.path || params.location; }); if (this.route.snapshot.data && this.route.snapshot.data.navigateSource) { @@ -420,7 +420,7 @@ export class AppViewerComponent implements OnInit, OnDestroy { } private getFileLocation(): string { - return this.router.parseUrl(this.navigationPath || this.router.url).root.children[PRIMARY_OUTLET].toString(); + return this.navigationPath || this.router.parseUrl(this.router.url).root.children[PRIMARY_OUTLET].toString(); } private shouldNavigate(element: HTMLElement): boolean {