From 4cae03ecb785569512eba1d6e3317006a1c93d34 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 13 Apr 2022 14:41:54 -0500 Subject: [PATCH] [Lens] Fixes partition legend visibility (#130090) (#130169) (cherry picked from commit 405a9cf2d72316cbf92f3aa6dde1b84cb53e8ac8) Co-authored-by: Stratoula Kalafateli --- .../public/components/partition_vis_component.tsx | 8 ++------ .../vis_types/pie/public/editor/components/pie.tsx | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/plugins/chart_expressions/expression_partition_vis/public/components/partition_vis_component.tsx b/src/plugins/chart_expressions/expression_partition_vis/public/components/partition_vis_component.tsx index c843bf189d77f..5db1412a11659 100644 --- a/src/plugins/chart_expressions/expression_partition_vis/public/components/partition_vis_component.tsx +++ b/src/plugins/chart_expressions/expression_partition_vis/public/components/partition_vis_component.tsx @@ -126,12 +126,8 @@ const PartitionVisComponent = (props: PartitionVisComponentProps) => { useEffect(() => { const legendShow = showLegendDefault(); - const showLegendDef = shouldShowLegend(visType, visParams.legendDisplay, bucketColumns); - if (showLegendDef !== legendShow) { - setShowLegend(legendShow); - props.uiState?.set('vis.legendOpen', legendShow); - } - }, [showLegendDefault, props.uiState, visParams.legendDisplay, visType, bucketColumns]); + setShowLegend(legendShow); + }, [showLegendDefault]); const onRenderChange = useCallback( (isRendered) => { diff --git a/src/plugins/vis_types/pie/public/editor/components/pie.tsx b/src/plugins/vis_types/pie/public/editor/components/pie.tsx index a8324570a9259..afda8e333a42b 100644 --- a/src/plugins/vis_types/pie/public/editor/components/pie.tsx +++ b/src/plugins/vis_types/pie/public/editor/components/pie.tsx @@ -104,8 +104,8 @@ const PieOptions = (props: PieOptionsProps) => { ); useEffect(() => { - setLegendVisibility(legendUiStateValue); - }, [legendUiStateValue]); + setLegendVisibility(legendUiStateValue ?? stateParams.legendDisplay === LegendDisplay.SHOW); + }, [legendUiStateValue, stateParams.legendDisplay]); useEffect(() => { const fetchPalettes = async () => {