diff --git a/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.tsx b/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.tsx index 40c43225db131..32c21008c2a3a 100644 --- a/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.tsx +++ b/src/legacy/core_plugins/vis_type_vislib/public/components/options/metrics_axes/index.tsx @@ -92,14 +92,14 @@ function MetricsAxisOptions(props: ValidationVisOptionsProps) const updateAxisTitle = useCallback( (seriesParams?: SeriesParam[]) => { const series = seriesParams || stateParams.seriesParams; - const axes = cloneDeep(stateParams.valueAxes); let isAxesChanged = false; let lastValuesChanged = false; const lastLabels = { ...lastCustomLabels }; const lastMatchingSeriesAgg = { ...lastSeriesAgg }; - stateParams.valueAxes.forEach((axis, axisNumber) => { + const axes = stateParams.valueAxes.map((axis, axisNumber) => { let newCustomLabel = ''; + let updatedAxis; const matchingSeries: IAggConfig[] = []; series.forEach((serie, seriesIndex) => { @@ -135,16 +135,19 @@ function MetricsAxisOptions(props: ValidationVisOptionsProps) (aggTypeIsChanged || aggFieldIsChanged || axis.title.text === '' || - lastCustomLabels[axis.id] === axis.title.text) + lastCustomLabels[axis.id] === axis.title.text) && + newCustomLabel !== axis.title.text ) { // Override axis title with new custom label - axes[axisNumber] = { + updatedAxis = { ...axis, title: { ...axis.title, text: newCustomLabel }, }; isAxesChanged = true; } } + + return updatedAxis || axis; }); if (isAxesChanged) {