From d3175135848b078596de1b95570683d1647e2314 Mon Sep 17 00:00:00 2001 From: dej611 Date: Thu, 11 Aug 2022 16:28:52 +0200 Subject: [PATCH] :bug: Fix the dataViews switch bug --- .../public/state_management/lens_slice.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/lens/public/state_management/lens_slice.ts b/x-pack/plugins/lens/public/state_management/lens_slice.ts index b5f9ec00287d5..b880b9478c16a 100644 --- a/x-pack/plugins/lens/public/state_management/lens_slice.ts +++ b/x-pack/plugins/lens/public/state_management/lens_slice.ts @@ -374,19 +374,20 @@ export const makeLensReducer = (storeDeps: LensStoreDeps) => { .getTableSpec() .map(({ columnId }) => columnId) .filter((columnId) => !nextTable.has(columnId)); - const nextVisState = (newState.visualization || state.visualization).state; const activeVisualization = visualizationMap[state.visualization.activeId]; + let nextVisState = (newState.visualization || state.visualization).state; removed.forEach((columnId) => { - newState.visualization = { - ...state.visualization, - state: activeVisualization.removeDimension({ - layerId, - columnId, - prevState: nextVisState, - frame, - }), - }; + nextVisState = activeVisualization.removeDimension({ + layerId, + columnId, + prevState: nextVisState, + frame, + }); }); + newState.visualization = { + ...state.visualization, + state: nextVisState, + }; } } }