From 891f4a2faf3b317cdf48a259376d1d31a0765a44 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 26 Jan 2026 09:12:03 -0800 Subject: [PATCH] Fix: correctly extract all ids for nested tags (#11888) --- .../management-list.component.spec.ts | 15 +++++++++++++++ .../management-list/management-list.component.ts | 2 +- src/documents/views.py | 10 +++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src-ui/src/app/components/manage/management-list/management-list.component.spec.ts b/src-ui/src/app/components/manage/management-list/management-list.component.spec.ts index 813c81148..86f0f0469 100644 --- a/src-ui/src/app/components/manage/management-list/management-list.component.spec.ts +++ b/src-ui/src/app/components/manage/management-list/management-list.component.spec.ts @@ -229,6 +229,21 @@ describe('ManagementListComponent', () => { expect(reloadSpy).toHaveBeenCalled() }) + it('should use the all list length for collection size when provided', fakeAsync(() => { + jest.spyOn(tagService, 'listFiltered').mockReturnValueOnce( + of({ + count: 1, + all: [1, 2, 3], + results: tags.slice(0, 1), + }) + ) + + component.reloadData() + tick(100) + + expect(component.collectionSize).toBe(3) + })) + it('should support quick filter for objects', () => { const qfSpy = jest.spyOn(documentListViewService, 'quickFilter') const filterButton = fixture.debugElement.queryAll(By.css('button'))[9] diff --git a/src-ui/src/app/components/manage/management-list/management-list.component.ts b/src-ui/src/app/components/manage/management-list/management-list.component.ts index b1af1f1d1..44160fcdf 100644 --- a/src-ui/src/app/components/manage/management-list/management-list.component.ts +++ b/src-ui/src/app/components/manage/management-list/management-list.component.ts @@ -171,7 +171,7 @@ export abstract class ManagementListComponent tap((c) => { this.unfilteredData = c.results this.data = this.filterData(c.results) - this.collectionSize = c.count + this.collectionSize = c.all?.length ?? c.count }), delay(100) ) diff --git a/src/documents/views.py b/src/documents/views.py index 4e0460dc9..a91ad8594 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -467,11 +467,11 @@ class TagViewSet(ModelViewSet, PermissionsAwareDocumentCountMixin): if descendant_pks: filter_q = self.get_document_count_filter() - children_source = ( + children_source = list( Tag.objects.filter(pk__in=descendant_pks | {t.pk for t in all_tags}) .select_related("owner") .annotate(document_count=Count("documents", filter=filter_q)) - .order_by(*ordering) + .order_by(*ordering), ) else: children_source = all_tags @@ -483,7 +483,11 @@ class TagViewSet(ModelViewSet, PermissionsAwareDocumentCountMixin): page = self.paginate_queryset(queryset) serializer = self.get_serializer(page, many=True) - return self.get_paginated_response(serializer.data) + response = self.get_paginated_response(serializer.data) + if descendant_pks: + # Include children in the "all" field, if needed + response.data["all"] = [tag.pk for tag in children_source] + return response def perform_update(self, serializer): old_parent = self.get_object().get_parent()