diff --git a/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts b/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts index d827435f1a..5ff23a9839 100644 --- a/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts +++ b/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts @@ -1023,6 +1023,46 @@ describe('DocumentList', () => { expect(documentList.currentFolderId).toBe('normal-folder'); }); + it('should reset filterValue and update currentFolderId when navigating with a string folder ID', () => { + documentList.filterValue = { name: 'test' }; + + const result = documentList.navigateTo('folder-123'); + + expect(result).toBeTrue(); + expect(documentList.filterValue).toEqual({}); + expect(documentList.currentFolderId).toBe('folder-123'); + }); + + it('should reset filterValue and update currentFolderId when navigating with a Node', () => { + const node = new Node({ id: 'node-456', isFolder: true }); + + spyOn(documentList, 'canNavigateFolder').and.returnValue(true); + documentList.filterValue = { name: 'test' }; + + const result = documentList.navigateTo(node); + + expect(result).toBeTrue(); + expect(documentList.filterValue).toEqual({}); + expect(documentList.currentFolderId).toBe('node-456'); + }); + + it('should update sorting and call reload when sorting is changed and preserve filterValue', () => { + const reloadSpy = spyOn(documentList, 'reload').and.callThrough(); + documentList.sortingMode = 'server'; + documentList.filterValue = { name: 'abc' }; + documentList.currentFolderId = 'folder-789'; + + const event = new CustomEvent('sortingChanged', { + detail: { sortingKey: 'name', direction: 'asc' } + }); + + documentList.onSortingChanged(event); + + expect(documentList.sorting).toEqual(['name', 'asc']); + expect(reloadSpy).toHaveBeenCalled(); + expect(documentList.filterValue).toEqual({ name: 'abc' }); + }); + it('should require valid node for file preview', () => { const file = new FileNode(); file.entry = null; diff --git a/lib/content-services/src/lib/document-list/components/document-list.component.ts b/lib/content-services/src/lib/document-list/components/document-list.component.ts index da1ea3054a..e889b8e1bf 100644 --- a/lib/content-services/src/lib/document-list/components/document-list.component.ts +++ b/lib/content-services/src/lib/document-list/components/document-list.component.ts @@ -719,6 +719,7 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On if (typeof node === 'string') { this.resetNewFolderPagination(); this.currentFolderId = node; + this.filterValue = {}; this.folderChange.emit(new NodeEntryEvent({ id: node } as Node)); this.reload(); return true; @@ -726,6 +727,7 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On if (this.canNavigateFolder(node)) { this.resetNewFolderPagination(); this.currentFolderId = this.getNodeFolderDestinationId(node); + this.filterValue = {}; this.folderChange.emit(new NodeEntryEvent({ id: this.currentFolderId } as Node)); this.reload(); return true;