From e82131b2f371dc00dbf7a80a5dedbb0001d82d9c Mon Sep 17 00:00:00 2001 From: Vignesh Joglekar Date: Wed, 1 Jun 2022 02:32:00 -0500 Subject: [PATCH] Fixes edge case on conversion metric automatic change (#1939) --- assets/js/dashboard/stats/graph/visitor-graph.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/assets/js/dashboard/stats/graph/visitor-graph.js b/assets/js/dashboard/stats/graph/visitor-graph.js index 6f3678067..88002f8fa 100644 --- a/assets/js/dashboard/stats/graph/visitor-graph.js +++ b/assets/js/dashboard/stats/graph/visitor-graph.js @@ -349,14 +349,12 @@ export default class VisitorGraph extends React.Component { const topStatLabels = topStatData && topStatData.top_stats.map(({ name }) => METRIC_MAPPING[name]).filter(name => name) const prevTopStatLabels = prevState.topStatData && prevState.topStatData.top_stats.map(({ name }) => METRIC_MAPPING[name]).filter(name => name) if (topStatLabels && `${topStatLabels}` !== `${prevTopStatLabels}`) { - if (!topStatLabels.includes(savedMetric) && savedMetric !== "") { - if (this.props.query.filters.goal && metric !== 'conversions') { - this.setState({ metric: 'conversions' }) - } else { - this.setState({ metric: topStatLabels[0] }) - } - } else { + if (this.props.query.filters.goal && metric !== 'conversions') { + this.setState({ metric: 'conversions' }) + } else if (topStatLabels.includes(savedMetric) && savedMetric !== "") { this.setState({ metric: savedMetric }) + } else { + this.setState({ metric: topStatLabels[0] }) } } }