From bf5ac0fe651a7b8e0f8cd0b65886330d762c1ace Mon Sep 17 00:00:00 2001 From: dej611 Date: Tue, 10 Nov 2020 15:29:56 +0100 Subject: [PATCH 1/5] :bug: Update the active dimension on close with last value in the state --- .../editor_frame/config_panel/layer_panel.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx index 0332f11aa78b3..6128b28f21deb 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx @@ -463,10 +463,12 @@ export function LayerPanel( prevState: props.visualizationState, }) ); - setActiveDimension({ - ...activeDimension, + // Many setActiveDimension calls may happen at once + // so pick the last update value and update it + setActiveDimension((prevActiveDimension) => ({ + ...prevActiveDimension, isNew: false, - }); + })); }, }} /> From 59ecc9c135b6da00b0caeeffa0e5056d42d5231a Mon Sep 17 00:00:00 2001 From: dej611 Date: Wed, 11 Nov 2020 18:21:35 +0100 Subject: [PATCH 2/5] :bug: Rework the fix at the operation level --- .../editor_frame/config_panel/layer_panel.tsx | 8 +++---- .../definitions/filters/filter_popover.tsx | 18 +++++++++++++--- .../definitions/ranges/advanced_editor.tsx | 21 +++++++++++++------ 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx index 6128b28f21deb..0332f11aa78b3 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.tsx @@ -463,12 +463,10 @@ export function LayerPanel( prevState: props.visualizationState, }) ); - // Many setActiveDimension calls may happen at once - // so pick the last update value and update it - setActiveDimension((prevActiveDimension) => ({ - ...prevActiveDimension, + setActiveDimension({ + ...activeDimension, isNew: false, - })); + }); }, }} /> diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filter_popover.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filter_popover.tsx index 077e07a89f788..85e041ac7a4b3 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filter_popover.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/filters/filter_popover.tsx @@ -58,13 +58,20 @@ export const FilterPopover = ({ isOpen={isOpenByCreation || isPopoverOpen} ownFocus closePopover={() => { - setPopoverOpen(false); + if (isOpenByCreation) { + setIsOpenByCreation(false); + } + if (isPopoverOpen) { + setIsPopoverOpen(false); + } }} button={