]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix: show children in tag list when filtering (#10899)
authorshamoon <4887959+shamoon@users.noreply.github.com>
Sun, 21 Sep 2025 17:09:05 +0000 (10:09 -0700)
committerGitHub <noreply@github.com>
Sun, 21 Sep 2025 17:09:05 +0000 (10:09 -0700)
src-ui/src/app/components/manage/tag-list/tag-list.component.spec.ts
src-ui/src/app/components/manage/tag-list/tag-list.component.ts

index 4e723993c3f9675cbc185fd9458d1ca1072f3791..b4694e14554e8e4669044b7572fe452af42d2c0a 100644 (file)
@@ -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)
+  })
 })
index 12481594f35d8d25ca539be05a5c6364848e73de..77d42e020ec0f7e2baab58db4ca562184046197e 100644 (file)
@@ -62,6 +62,8 @@ export class TagListComponent extends ManagementListComponent<Tag> {
   }
 
   filterData(data: Tag[]) {
-    return data.filter((tag) => !tag.parent)
+    return this.nameFilter?.length
+      ? [...data]
+      : data.filter((tag) => !tag.parent)
   }
 }