[v10.4.x] Dashboard: Fix issue where out-of-view shared query panels caused blank dependent panels (#84197)

Dashboard: Fix issue where out-of-view shared query panels caused blank dependent panels (#83966)

(cherry picked from commit d8b8a2c2b0)

Co-authored-by: kay delaney <45561153+kaydelaney@users.noreply.github.com>
This commit is contained in:
grafana-delivery-bot[bot]
2024-03-11 17:10:52 +02:00
committed by GitHub
co-authored by kay delaney
parent 7f48c3168b
commit 32e7839cb8
3 changed files with 17 additions and 4 deletions
@@ -74,6 +74,8 @@ function setupTestContext(options: Partial<Props>) {
</Provider>
);
// Needed so mocks work
props.panel.refreshWhenInView = false;
return { rerender, props, subject, store };
}
@@ -440,11 +440,22 @@ export class DashboardModel implements TimeModel {
return;
}
for (const panel of this.panels) {
if (!this.otherPanelInFullscreen(panel) && (event.refreshAll || event.panelIds.includes(panel.id))) {
panel.refresh();
const panelsToRefresh = this.panels.filter(
(panel) => !this.otherPanelInFullscreen(panel) && (event.refreshAll || event.panelIds.includes(panel.id))
);
// We have to mark every panel as refreshWhenInView /before/ we actually refresh any
// in case there is a shared query, as otherwise that might refresh before the source panel is
// marked for refresh, preventing the panel from updating
if (!this.isSnapshot()) {
for (const panel of panelsToRefresh) {
panel.refreshWhenInView = true;
}
}
for (const panel of panelsToRefresh) {
panel.refresh();
}
}
render() {
@@ -203,7 +203,7 @@ export class PanelModel implements DataConfigSource, IPanelModel {
cacheTimeout?: string | null;
queryCachingTTL?: number | null;
isNew?: boolean;
refreshWhenInView = false;
refreshWhenInView = true;
cachedPluginOptions: Record<string, PanelOptionsCache> = {};
legend?: { show: boolean; sort?: string; sortDesc?: boolean };