From 8cc566792af66617bd6950063257bb9a3fd51d10 Mon Sep 17 00:00:00 2001 From: Mayur Newase Date: Thu, 10 Dec 2020 13:00:57 +0530 Subject: [PATCH] fix(explore): changing metric aggregate doesn't update label (#11946) * fix: [chart]heatmap selecting metrics does not update the query results fixes issue #11866 title's label is overriding metric label. * Using custom label to decide label of metrics. * lint * Tests fixed * early metric label check while saving from ui * early custom label check * removed extra space * no state mutations * simplify * removed log * nned to fix linting issue * Lint fixed --- .../explore/components/AdhocMetricEditPopover.jsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/superset-frontend/src/explore/components/AdhocMetricEditPopover.jsx b/superset-frontend/src/explore/components/AdhocMetricEditPopover.jsx index 320494812f..da1cde11cc 100644 --- a/superset-frontend/src/explore/components/AdhocMetricEditPopover.jsx +++ b/superset-frontend/src/explore/components/AdhocMetricEditPopover.jsx @@ -100,10 +100,19 @@ export default class AdhocMetricEditPopover extends React.Component { } onSave() { - // unset isNew here in case save button was clicked when no changes were made + const { title } = this.props; + const { hasCustomLabel } = title; + let { label } = title; + const { adhocMetric } = this.state; + const metricLabel = adhocMetric.label; + if (!hasCustomLabel) { + label = metricLabel; + } this.props.onChange({ - ...this.state.adhocMetric, - ...this.props.title, + ...adhocMetric, + label, + hasCustomLabel, + // unset isNew here in case save button was clicked when no changes were made isNew: false, }); this.props.onClose();