From 04f6de1c4a135660ba393d6ac4846bbbc10b5bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=C3=A1nchez?= Date: Mon, 5 Oct 2026 14:14:08 -0600 Subject: [PATCH] fix[frontend](dashboards): added visualizations update after edition --- .../dashboard/hooks/useVisualizationData.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/frontend/src/features/dashboard/hooks/useVisualizationData.ts b/frontend/src/features/dashboard/hooks/useVisualizationData.ts index 593ad80ce..a846121c5 100644 --- a/frontend/src/features/dashboard/hooks/useVisualizationData.ts +++ b/frontend/src/features/dashboard/hooks/useVisualizationData.ts @@ -15,8 +15,8 @@ const EMPTY_FILTERS: FilterType[] = [] export const VISUALIZATION_DATA_QUERY_KEYS = { all: ['visualization-data'] as const, - forViz: (vizId: string, fromISO: string, toISO: string, filtersKey: string) => - [...VISUALIZATION_DATA_QUERY_KEYS.all, vizId, fromISO, toISO, filtersKey] as const, + forViz: (vizId: string, fromISO: string, toISO: string, filtersKey: string, specKey: string) => + [...VISUALIZATION_DATA_QUERY_KEYS.all, vizId, fromISO, toISO, filtersKey, specKey] as const, } export interface VisualizationData { @@ -63,7 +63,16 @@ export function useVisualizationData( return useQuery({ queryKey: visualization - ? VISUALIZATION_DATA_QUERY_KEYS.forViz(visualization.id, fromISO, toISO, filtersKey) + ? VISUALIZATION_DATA_QUERY_KEYS.forViz( + visualization.id, + fromISO, + toISO, + filtersKey, + // The saved spec decides what the backend queries. Without it in the + // key, editing a widget leaves the old data cached and staleTime + // keeps serving it after returning to the dashboard. + visualization.spec, + ) : [...VISUALIZATION_DATA_QUERY_KEYS.all, 'noop'], queryFn: async () => { if (!spec) return { rows: [], total: 0 }