From 6888986c5918166ed0c92ee53013f7d39385dad3 Mon Sep 17 00:00:00 2001 From: goerch Date: Sun, 24 May 2026 13:30:06 +0200 Subject: [PATCH] Fix pivot table config after browser refresh (#9489) --- .../dashboards/stores/dashboard-stores.ts | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/web-common/src/features/dashboards/stores/dashboard-stores.ts b/web-common/src/features/dashboards/stores/dashboard-stores.ts index 2d30bce5d9ff..37ac466a7374 100644 --- a/web-common/src/features/dashboards/stores/dashboard-stores.ts +++ b/web-common/src/features/dashboards/stores/dashboard-stores.ts @@ -103,10 +103,6 @@ function syncMeasures(explore: V1ExploreSpec, exploreState: ExploreState) { exploreState.tdd.expandedMeasureName = undefined; } - exploreState.pivot.columns = exploreState.pivot.columns.filter((measure) => - measuresSet.has(measure.id), - ); - if (exploreState.allMeasuresVisible) { // this makes sure that the visible keys is in sync with list of measures exploreState.visibleMeasures = [...measuresSet]; @@ -140,16 +136,6 @@ function syncDimensions(explore: V1ExploreSpec, exploreState: ExploreState) { exploreState.activePage = DashboardState_ActivePage.DEFAULT; } - exploreState.pivot.rows = exploreState.pivot.rows.filter( - (dimension) => - dimensionsSet.has(dimension.id) || dimension.type === PivotChipType.Time, - ); - - exploreState.pivot.columns = exploreState.pivot.columns.filter( - (dimension) => - dimensionsSet.has(dimension.id) || dimension.type === PivotChipType.Time, - ); - if (exploreState.allDimensionsVisible) { // this makes sure that the visible keys is in sync with list of dimensions exploreState.visibleDimensions = [...dimensionsSet]; @@ -161,6 +147,23 @@ function syncDimensions(explore: V1ExploreSpec, exploreState: ExploreState) { } } +function syncPivot(explore: V1ExploreSpec, exploreState: ExploreState) { + const measuresSet = new Set(explore.measures ?? []); + const dimensionsSet = new Set(explore.dimensions ?? []); + + exploreState.pivot.rows = exploreState.pivot.rows.filter( + (dimension) => + dimensionsSet.has(dimension.id) || + dimension.type === PivotChipType.Time, + ); + exploreState.pivot.columns = exploreState.pivot.columns.filter( + (column) => + measuresSet.has(column.id) || + dimensionsSet.has(column.id) || + column.type === PivotChipType.Time, + ); +} + const metricsViewReducers = { init(name: string, initState: ExploreState) { update((state) => { @@ -234,6 +237,9 @@ const metricsViewReducers = { // remove references to non existent dimensions syncDimensions(explore, exploreState); + + // synchronize pivot rows & columns + syncPivot(explore, exploreState); }); },