From 3dae00aa3e42e132b0c1162de8619704e6f31157 Mon Sep 17 00:00:00 2001 From: Shruthilaya Date: Fri, 22 Oct 2021 08:56:04 -0400 Subject: [PATCH] fix(dashboards): Fix inconsistent labels It seems because of the async nature of the promises being resolved for widget queries, simply concating raw results doesn't work because the order isn't ensured. Instead, we want to use the index as a key here so that we can always ensure the raw results are in the same order as the widgetQueries. --- static/app/views/dashboardsV2/widgetQueries.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/static/app/views/dashboardsV2/widgetQueries.tsx b/static/app/views/dashboardsV2/widgetQueries.tsx index 96f44513b262a0..2c20e8617ef5f9 100644 --- a/static/app/views/dashboardsV2/widgetQueries.tsx +++ b/static/app/views/dashboardsV2/widgetQueries.tsx @@ -1,4 +1,5 @@ import * as React from 'react'; +import cloneDeep from 'lodash/cloneDeep'; import isEqual from 'lodash/isEqual'; import {doEventsRequest} from 'app/actionCreators/events'; @@ -339,10 +340,13 @@ class WidgetQueries extends React.Component { transformResult(widget.queries[i], rawResults) ); + const rawResultsClone = cloneDeep(prevState.rawResults ?? []); + rawResultsClone[i] = rawResults; + return { ...prevState, timeseriesResults, - rawResults: (prevState.rawResults ?? []).concat(rawResults), + rawResults: rawResultsClone, }; }); } catch (err) {