sadpandajoe commented on code in PR #44629:
URL: https://github.com/apache/superset/pull/44629#discussion_r4137075811
##########
superset-frontend/packages/superset-ui-core/src/chart/components/Matrixify/MatrixifyGridGenerator.ts:
##########
@@ -134,6 +134,30 @@ function appendMatrixifyFilters(
});
}
+/**
+ * Apply the matrix's chosen metrics to the primary `metrics` collection as
well
+ * as every query-specific `metrics_*` collection present on the formData (plus
+ * the singular `metric` field used by single-metric viz types). Charts with
+ * more than one query (e.g. Mixed Chart) read each query's metrics from a
+ * separate collection (`metrics_b`, `metrics_c`, ...), so a cell's chosen
+ * metrics must overwrite all of them, not just the primary query's.
+ */
+function overrideMatrixifyMetrics(
+ formData: QueryFormData & MatrixifyFormData,
+ metrics: AdhocMetric[],
+): void {
+ const metricsFields: Record<string, unknown> = formData;
+ const metricsKeys = [
+ 'metrics',
+ ...Object.keys(metricsFields).filter(key => /^metrics_.+$/u.test(key)),
+ ];
+
+ metricsKeys.forEach(key => {
+ metricsFields[key] = metrics;
Review Comment:
Fixed in b023dde1f8 — `overrideMatrixifyMetrics` now spreads a fresh array
per key (`[...metrics]`) instead of sharing one reference across
`metrics`/`metrics_b`/etc., matching `appendMatrixifyFilters`'s existing
pattern. Added a regression test asserting the per-key arrays aren't the same
reference.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]