From 172febd690db7f5dc78a804384fbfbc4d23dd8f7 Mon Sep 17 00:00:00 2001 From: Bogdan Matei Date: Mon, 15 Sep 2025 13:41:06 +0300 Subject: [PATCH] Dashboard: Do not issue queries for panels outside the viewport (#111067) --- package.json | 4 ++-- .../datasource/dashboard/datasource.ts | 14 ++++++++++-- yarn.lock | 22 +++++++++---------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 22095887212..b269774ebd8 100644 --- a/package.json +++ b/package.json @@ -286,8 +286,8 @@ "@grafana/plugin-ui": "^0.10.10", "@grafana/prometheus": "workspace:*", "@grafana/runtime": "workspace:*", - "@grafana/scenes": "6.35.0", - "@grafana/scenes-react": "6.35.0", + "@grafana/scenes": "6.35.3", + "@grafana/scenes-react": "6.35.3", "@grafana/schema": "workspace:*", "@grafana/sql": "workspace:*", "@grafana/ui": "workspace:*", diff --git a/public/app/plugins/datasource/dashboard/datasource.ts b/public/app/plugins/datasource/dashboard/datasource.ts index 2386418231a..8f945bad984 100644 --- a/public/app/plugins/datasource/dashboard/datasource.ts +++ b/public/app/plugins/datasource/dashboard/datasource.ts @@ -87,7 +87,13 @@ export class DashboardDatasource extends DataSourceApi { sourceDataProvider?.setContainerWidth(500); } - const cleanUp = activateSceneObjectAndParentTree(sourceDataProvider!); + /** + * Ignore the isInView flag on the original data provider + * This allows queries to be run even if the original datasource is outside the viewport + */ + sourceDataProvider?.bypassIsInViewChanged?.(true); + + const activateCleanUp = activateSceneObjectAndParentTree(sourceDataProvider!); return sourceDataProvider!.getResultsStream!().pipe( debounceTime(50), @@ -101,7 +107,11 @@ export class DashboardDatasource extends DataSourceApi { }; }), this.emitFirstLoadedDataIfMixedDS(options.requestId), - finalize(() => cleanUp?.()) + finalize(() => { + sourceDataProvider?.bypassIsInViewChanged?.(false); + + activateCleanUp?.(); + }) ); }); } diff --git a/yarn.lock b/yarn.lock index 55a99589c60..4a0e5b58b1e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3521,11 +3521,11 @@ __metadata: languageName: unknown linkType: soft -"@grafana/scenes-react@npm:6.35.0": - version: 6.35.0 - resolution: "@grafana/scenes-react@npm:6.35.0" +"@grafana/scenes-react@npm:6.35.3": + version: 6.35.3 + resolution: "@grafana/scenes-react@npm:6.35.3" dependencies: - "@grafana/scenes": "npm:6.35.0" + "@grafana/scenes": "npm:6.35.3" lru-cache: "npm:^10.2.2" react-use: "npm:^17.4.0" peerDependencies: @@ -3537,13 +3537,13 @@ __metadata: react: ^18.0.0 react-dom: ^18.0.0 react-router-dom: ^6.28.0 - checksum: 10/7f4f3b2c23137adb0dc71b2fe93e92c41e2f71fc91d1f7a1432f04946841220dc27941f021af74642ebc3b58467c482e1349b8b7e0d490b78f3a33f8671fda85 + checksum: 10/2c220eef6aa8560d073a27a02918b4bbf4d0cffee273ff597e94eb4376e75d0e47fcdaa2cd1ca8ea851c29477722dec2e2d2f817f2c5c185151de2051c5e2ab7 languageName: node linkType: hard -"@grafana/scenes@npm:6.35.0": - version: 6.35.0 - resolution: "@grafana/scenes@npm:6.35.0" +"@grafana/scenes@npm:6.35.3": + version: 6.35.3 + resolution: "@grafana/scenes@npm:6.35.3" dependencies: "@floating-ui/react": "npm:^0.26.16" "@leeoniya/ufuzzy": "npm:^1.0.16" @@ -3563,7 +3563,7 @@ __metadata: react: ^18.0.0 react-dom: ^18.0.0 react-router-dom: ^6.28.0 - checksum: 10/4a9ff88c2a6cfafe5aaa7d50b8ee67ab38f105b3073cab4469665338e28c9991fb9b908c0325680cc32525a87ebcd34c3d376d940a4f9b9b684c8db238f02527 + checksum: 10/a209e6a1cbe6c4e70c2cd8c413df2560a59b157944888e317385f19e43e23ff826d84c922618b1268a7085278aca45a369c8f6255bf70a06134622c6ef2a542e languageName: node linkType: hard @@ -18168,8 +18168,8 @@ __metadata: "@grafana/plugin-ui": "npm:^0.10.10" "@grafana/prometheus": "workspace:*" "@grafana/runtime": "workspace:*" - "@grafana/scenes": "npm:6.35.0" - "@grafana/scenes-react": "npm:6.35.0" + "@grafana/scenes": "npm:6.35.3" + "@grafana/scenes-react": "npm:6.35.3" "@grafana/schema": "workspace:*" "@grafana/sql": "workspace:*" "@grafana/test-utils": "workspace:*"