explicitly reset ds.hidden in the hiddenLabels block

Address Greptile P1 review on PR #4259. The hiddenLabels loop only
wrote ds.hidden = true and never reset to false when a label was
removed from the set. Toggle-off worked today only because the
focusLabel block above ran first and unconditionally cleared all
ds.hidden when focusLabel was falsy. That block is guarded by
chartData.focusLabel !== null, so any caller passing focusLabel={null}
would skip the reset and leave a stale true on reused dataset objects
across effect re-runs, making un-hide silently fail.

Add an else-if branch to the hiddenLabels loop that resets ds.hidden
to false when the label is not in the set and no focusLabel is
active. Behavior is unchanged for EventsChart (which never passes a
null focusLabel) and the contract of the new props is now independent
of execution order.
This commit is contained in:
Yan committed 2026-05-08 09:35:09 -04:00
1 parent 4f72d17faf
commit d0049e70b5
1 file changed
+4
+4
View File
@@ -131,6 +131,10 @@ export function Chart({
chart.current.data.datasets.forEach((ds: { hidden: boolean; label: any }) => {
if (hiddenLabels.has(ds.label)) {
ds.hidden = true;
} else if (!chartData.focusLabel) {
// Explicitly reset so un-hiding a label is always reflected,
// regardless of whether the focusLabel pass ran above.
ds.hidden = false;
}
});
}