From d9c875d343cf64f6d9fa5e9201cf6dc896e03415 Mon Sep 17 00:00:00 2001 From: Will Assis <35489495+gassiss@users.noreply.github.com> Date: Wed, 3 Sep 2025 19:50:58 -0400 Subject: [PATCH] fix: dashboard list page bugs while in mode 3 (#110568) * fix infinite scroll when using folder tree view in dashboard page inside folders with more than 50 items * fix off-by-one error when fetching in list view --- public/app/features/browse-dashboards/api/services.test.ts | 1 + public/app/features/browse-dashboards/api/services.ts | 1 + public/app/features/search/service/types.ts | 1 + public/app/features/search/service/unified.ts | 6 +++++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/public/app/features/browse-dashboards/api/services.test.ts b/public/app/features/browse-dashboards/api/services.test.ts index e0a3ea9fd85..456dfcb637e 100644 --- a/public/app/features/browse-dashboards/api/services.test.ts +++ b/public/app/features/browse-dashboards/api/services.test.ts @@ -44,6 +44,7 @@ describe('browse-dashboards services', () => { location: 'abc-123', from: expectedFrom, limit: PAGE_SIZE, + offset: expectedFrom, }); }); }); diff --git a/public/app/features/browse-dashboards/api/services.ts b/public/app/features/browse-dashboards/api/services.ts index 3d37d5dafd1..9bc948b89f5 100644 --- a/public/app/features/browse-dashboards/api/services.ts +++ b/public/app/features/browse-dashboards/api/services.ts @@ -51,6 +51,7 @@ export async function listDashboards(parentUID?: string, page = 1, pageSize = PA location: parentUID || 'general', from: (page - 1) * pageSize, // our pages are 1-indexed, so we need to -1 to convert that to correct value to skip limit: pageSize, + offset: (page - 1) * pageSize, }); return dashboardsResults.view.map((item) => { diff --git a/public/app/features/search/service/types.ts b/public/app/features/search/service/types.ts index 3ebda023037..cd043a2f8fe 100644 --- a/public/app/features/search/service/types.ts +++ b/public/app/features/search/service/types.ts @@ -41,6 +41,7 @@ export interface SearchQuery { starred?: boolean; permission?: PermissionLevelString; deleted?: boolean; + offset?: number; } export interface DashboardQueryResult { diff --git a/public/app/features/search/service/unified.ts b/public/app/features/search/service/unified.ts index a3881b09acc..1f5aef6c033 100644 --- a/public/app/features/search/service/unified.ts +++ b/public/app/features/search/service/unified.ts @@ -202,7 +202,7 @@ export class UnifiedSearcher implements GrafanaSearcher { totalRows: meta.count ?? first.length, view, loadMoreItems: async (startIndex: number, stopIndex: number): Promise => { - loadMax = Math.max(loadMax, stopIndex); + loadMax = Math.max(loadMax, stopIndex + 1); if (!pending) { pending = getNextPage(); } @@ -260,6 +260,10 @@ export class UnifiedSearcher implements GrafanaSearcher { uri += `?query=${encodeURIComponent(query.query ?? '*')}`; uri += `&limit=${query.limit ?? pageSize}`; + if (query.offset) { + uri += `&offset=${query.offset}`; + } + if (!isEmpty(query.location)) { uri += `&folder=${query.location}`; }