From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 21 Sep 2025 17:09:05 +0000 (-0700) Subject: Fix: show children in tag list when filtering (#10899) X-Git-Tag: v2.19.0~67 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=19ff339804486ed1e2b6982ccceb8f8965c06f77;p=thirdparty%2Fpaperless-ngx.git Fix: show children in tag list when filtering (#10899) --- diff --git a/src-ui/src/app/components/manage/tag-list/tag-list.component.spec.ts b/src-ui/src/app/components/manage/tag-list/tag-list.component.spec.ts index 4e723993c3..b4694e1455 100644 --- a/src-ui/src/app/components/manage/tag-list/tag-list.component.spec.ts +++ b/src-ui/src/app/components/manage/tag-list/tag-list.component.spec.ts @@ -71,4 +71,20 @@ describe('TagListComponent', () => { 'Do you really want to delete the tag "Tag1"?' ) }) + + it('should filter out child tags if name filter is empty, otherwise show all', () => { + const tags = [ + { id: 1, name: 'Tag1', parent: null }, + { id: 2, name: 'Tag2', parent: 1 }, + { id: 3, name: 'Tag3', parent: null }, + ] + component['_nameFilter'] = null // Simulate empty name filter + const filtered = component.filterData(tags as any) + expect(filtered.length).toBe(2) + expect(filtered.find((t) => t.id === 2)).toBeUndefined() + + component['_nameFilter'] = 'Tag2' // Simulate non-empty name filter + const filteredWithName = component.filterData(tags as any) + expect(filteredWithName.length).toBe(3) + }) }) diff --git a/src-ui/src/app/components/manage/tag-list/tag-list.component.ts b/src-ui/src/app/components/manage/tag-list/tag-list.component.ts index 12481594f3..77d42e020e 100644 --- a/src-ui/src/app/components/manage/tag-list/tag-list.component.ts +++ b/src-ui/src/app/components/manage/tag-list/tag-list.component.ts @@ -62,6 +62,8 @@ export class TagListComponent extends ManagementListComponent { } filterData(data: Tag[]) { - return data.filter((tag) => !tag.parent) + return this.nameFilter?.length + ? [...data] + : data.filter((tag) => !tag.parent) } }