From 13e07844fee16d9f650f0f9e50fb5eb0a3323fa7 Mon Sep 17 00:00:00 2001
From: shamoon <4887959+shamoon@users.noreply.github.com>
Date: Wed, 25 Feb 2026 17:25:36 -0800
Subject: [PATCH] Fix: separate displayed and API collection sizes for tags
(#12170)
---
.../management-list/management-list.component.html | 4 ++--
.../management-list.component.spec.ts | 5 +++--
.../management-list/management-list.component.ts | 13 ++++++++++++-
.../manage/tag-list/tag-list.component.ts | 11 +++++++++++
4 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/src-ui/src/app/components/manage/management-list/management-list.component.html b/src-ui/src/app/components/manage/management-list/management-list.component.html
index 8fac6f44f..91dcc2592 100644
--- a/src-ui/src/app/components/manage/management-list/management-list.component.html
+++ b/src-ui/src/app/components/manage/management-list/management-list.component.html
@@ -62,9 +62,9 @@
@if (!loading) {
- @if (collectionSize > 0) {
+ @if (displayCollectionSize > 0) {
- {collectionSize, plural, =1 {One {{typeName}}} other {{{collectionSize || 0}} total {{typeNamePlural}}}}
+ {displayCollectionSize, plural, =1 {One {{typeName}}} other {{{displayCollectionSize || 0}} total {{typeNamePlural}}}}
@if (selectedObjects.size > 0) {
({{selectedObjects.size}} selected)
}
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 86f0f0469..fb0ad0914 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,7 +229,7 @@ describe('ManagementListComponent', () => {
expect(reloadSpy).toHaveBeenCalled()
})
- it('should use the all list length for collection size when provided', fakeAsync(() => {
+ it('should use API count for pagination and all ids for displayed total', fakeAsync(() => {
jest.spyOn(tagService, 'listFiltered').mockReturnValueOnce(
of({
count: 1,
@@ -241,7 +241,8 @@ describe('ManagementListComponent', () => {
component.reloadData()
tick(100)
- expect(component.collectionSize).toBe(3)
+ expect(component.collectionSize).toBe(1)
+ expect(component.displayCollectionSize).toBe(3)
}))
it('should support quick filter for objects', () => {
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 27913ea7d..8c41f1c45 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
@@ -23,6 +23,7 @@ import {
MatchingModel,
} from 'src/app/data/matching-model'
import { ObjectWithPermissions } from 'src/app/data/object-with-permissions'
+import { Results } from 'src/app/data/results'
import {
SortableDirective,
SortEvent,
@@ -88,6 +89,7 @@ export abstract class ManagementListComponent
public page = 1
public collectionSize = 0
+ public displayCollectionSize = 0
public sortField: string
public sortReverse: boolean
@@ -141,6 +143,14 @@ export abstract class ManagementListComponent
return data
}
+ protected getCollectionSize(results: Results): number {
+ return results.all?.length ?? results.count
+ }
+
+ protected getDisplayCollectionSize(results: Results): number {
+ return this.getCollectionSize(results)
+ }
+
getDocumentCount(object: MatchingModel): number {
return (
object.document_count ??
@@ -171,7 +181,8 @@ export abstract class ManagementListComponent
tap((c) => {
this.unfilteredData = c.results
this.data = this.filterData(c.results)
- this.collectionSize = c.all?.length ?? c.count
+ this.collectionSize = this.getCollectionSize(c)
+ this.displayCollectionSize = this.getDisplayCollectionSize(c)
}),
delay(100)
)
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 0ba0a0855..3749a147f 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
@@ -7,6 +7,7 @@ import {
} from '@ng-bootstrap/ng-bootstrap'
import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons'
import { FILTER_HAS_TAGS_ALL } from 'src/app/data/filter-rule-type'
+import { Results } from 'src/app/data/results'
import { Tag } from 'src/app/data/tag'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { SortableDirective } from 'src/app/directives/sortable.directive'
@@ -77,6 +78,16 @@ export class TagListComponent extends ManagementListComponent {
return data.filter((tag) => !tag.parent || !availableIds.has(tag.parent))
}
+ protected override getCollectionSize(results: Results): number {
+ // Tag list pages are requested with is_root=true (when unfiltered), so
+ // pagination must follow root count even though `all` includes descendants
+ return results.count
+ }
+
+ protected override getDisplayCollectionSize(results: Results): number {
+ return super.getCollectionSize(results)
+ }
+
protected override getSelectableIDs(tags: Tag[]): number[] {
const ids: number[] = []
for (const tag of tags.filter(Boolean)) {