Skip to content

Commit 80270b0

Browse files
authored
fix(widget-legend): Skip prettify for pushing params to URL (#97513)
The URL params needs the actual value, not the prettified user facing value. This fixes `count(spans)` from not being togglable in charts.
1 parent 5132c32 commit 80270b0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

static/app/views/dashboards/widgetLegendNameEncoderDecoder.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ const WidgetLegendNameEncoderDecoder = {
1313
return `${seriesName}${SERIES_NAME_DELIMITER}${widgetId}`;
1414
},
1515

16-
decodeSeriesNameForLegend(encodedSeriesName: string) {
16+
decodeSeriesNameForLegend(encodedSeriesName: string, skipPrettify = false) {
1717
let seriesName = encodedSeriesName.split(SERIES_NAME_DELIMITER)[0];
1818
if (!seriesName) {
1919
return '';
2020
}
2121

2222
// If the series name contains an aggregate function, prettify it
2323
const functionMatch = seriesName.match(AGGREGATE_BASE);
24-
if (functionMatch?.[0] && parseFunction(functionMatch[0])) {
24+
if (!skipPrettify && functionMatch?.[0] && parseFunction(functionMatch[0])) {
2525
seriesName = seriesName.replace(
2626
functionMatch[0],
2727
prettifyParsedFunction(parseFunction(functionMatch[0])!)

static/app/views/dashboards/widgetLegendSelectionState.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type LegendSelection = Record<string, boolean>;
1919
const SERIES_LIST_DELIMITER = ',';
2020
const WIDGET_ID_DELIMITER = ':';
2121

22-
const SERIES_NAME_DELIMITER = ';';
22+
const SERIES_NAME_DELIMITER = '|~|';
2323

2424
class WidgetLegendSelectionState {
2525
dashboard: DashboardDetails | null;
@@ -177,7 +177,7 @@ class WidgetLegendSelectionState {
177177
.filter(key => !selected[key])
178178
.map(series =>
179179
encodeURIComponent(
180-
WidgetLegendNameEncoderDecoder.decodeSeriesNameForLegend(series)
180+
WidgetLegendNameEncoderDecoder.decodeSeriesNameForLegend(series, true)
181181
)
182182
)
183183
.join(SERIES_LIST_DELIMITER)

0 commit comments

Comments
 (0)