Skip to content

Conversation

@DominikB2014
Copy link
Contributor

When dashboards uses the new charts, we now:

  1. update the url when you select/deselect series in the legend
  2. respect the url selection on pageload

Additionally, the widget legend state allows releases to be on or off by default. For the new charts, we have them on by default.

@linear
Copy link

linear bot commented Dec 29, 2025

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Dec 29, 2025
@DominikB2014 DominikB2014 marked this pull request as ready for review December 29, 2025 18:57
@DominikB2014 DominikB2014 requested a review from a team as a code owner December 29, 2025 18:57
Comment on lines +61 to +67
const releasesSelectionDiffersFromDefault =
releasesKey in selected && selected[releasesKey] !== showReleaseByDefault;

const thisWidgetWithoutReleasesWasSelected =
!Object.keys(selected).includes(`Releases${SERIES_NAME_DELIMITER}${widget.id}`) &&
Object.values(selected).filter(value => value === false).length === 1;
!(releasesKey in selected) &&
Object.values(selected).filter(value => value === showReleaseByDefault).length ===
1;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The condition for thisWidgetWithoutReleasesWasSelected incorrectly checks against showReleaseByDefault instead of false, preventing correct URL updates when only the releases series is deselected.
Severity: HIGH | Confidence: High

🔍 Detailed Analysis

The logic to determine if a widget's release series was the only unselected item is flawed. The variable thisWidgetWithoutReleasesWasSelected now compares the number of selected series against showReleaseByDefault. However, the URL is updated by encoding unselected series (where the value is false). When showReleaseByDefault is true, the condition incorrectly checks if exactly one item is selected, rather than if exactly one item is unselected. This will prevent the URL from being updated correctly when the user modifies the legend selection for widgets where releases are shown by default.

💡 Suggested Fix

The condition should check for exactly one unselected item, regardless of the default visibility. Change Object.values(selected).filter(value => value === showReleaseByDefault).length === 1 back to Object.values(selected).filter(value => value === false).length === 1 to align with the URL encoding logic that tracks unselected series.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: static/app/views/dashboards/widgetLegendSelectionState.tsx#L61-L67

Potential issue: The logic to determine if a widget's release series was the only
unselected item is flawed. The variable `thisWidgetWithoutReleasesWasSelected` now
compares the number of selected series against `showReleaseByDefault`. However, the URL
is updated by encoding *unselected* series (where the value is `false`). When
`showReleaseByDefault` is `true`, the condition incorrectly checks if exactly one item
is selected, rather than if exactly one item is unselected. This will prevent the URL
from being updated correctly when the user modifies the legend selection for widgets
where releases are shown by default.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 8001953

Comment on lines 154 to 160
[WidgetLegendNameEncoderDecoder.encodeSeriesNameForLegend(
'Releases',
widget.id
)]: false,
)]: this.shouldShowReleaseByDefault(widget),
}
: {};
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: getWidgetSelectionState doesn't provide a default 'Releases' legend state for BAR charts, even though they support timeseries, because it incorrectly checks widgetRequiresLegendUnselection().
Severity: HIGH | Confidence: High

🔍 Detailed Analysis

The function getWidgetSelectionState fails to provide a default legend state for BAR chart widgets, even though they support timeseries visualization and are intended to show releases by default. The logic only returns a default state for widgets where widgetRequiresLegendUnselection() is true, which is limited to AREA and LINE charts. As a result, when the dashboards-widget-timeseries-visualization feature is enabled, BAR charts will be initialized with an empty legendSelection, failing to display the 'Releases' series in the legend by default as intended.

💡 Suggested Fix

The condition in getWidgetSelectionState should be based on whether the widget supports the new timeseries visualization, not just if it requires legend unselection. Change the condition from this.widgetRequiresLegendUnselection(widget) to this.shouldShowReleaseByDefault(widget) to ensure all timeseries-capable charts, including BAR charts, receive the default 'Releases' legend state.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: static/app/views/dashboards/widgetLegendSelectionState.tsx#L154-L160

Potential issue: The function `getWidgetSelectionState` fails to provide a default
legend state for `BAR` chart widgets, even though they support timeseries visualization
and are intended to show releases by default. The logic only returns a default state for
widgets where `widgetRequiresLegendUnselection()` is true, which is limited to `AREA`
and `LINE` charts. As a result, when the `dashboards-widget-timeseries-visualization`
feature is enabled, `BAR` charts will be initialized with an empty `legendSelection`,
failing to display the 'Releases' series in the legend by default as intended.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 8001953

1;

if (thisWidgetWithReleasesWasSelected || thisWidgetWithoutReleasesWasSelected) {
if (releasesSelectionDiffersFromDefault || thisWidgetWithoutReleasesWasSelected) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URL not updated when hiding non-releases series for first time

When there's no unselectedSeries in the URL and a user hides a non-Releases series for the first time, the URL won't be updated. The new condition releasesSelectionDiffersFromDefault only checks if the Releases series state differs from default, but fails to detect when other series are hidden. The old logic checked if the count of hidden series (value === false) changed from the default, which correctly detected all legend changes. Additionally, thisWidgetWithoutReleasesWasSelected incorrectly filters for value === showReleaseByDefault when it should always check for value === false (hidden series).

Fix in Cursor Fix in Web

@DominikB2014 DominikB2014 marked this pull request as draft December 30, 2025 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants