From 84fe25af928d7c1e97fc9bf8067c8111b6816913 Mon Sep 17 00:00:00 2001 From: Yan <75355375+yancat160@users.noreply.github.com> Date: Fri, 8 May 2026 09:35:43 -0400 Subject: [PATCH] read willBeHidden from hiddenLabels in handleLegendClick Address Greptile P2 review on PR #4259. willBeHidden was derived from !ds.hidden, but ds.hidden can be set by the focusLabel pass too, so the dataset flag is not a faithful read of the controlled hidden state. In a chart that uses both focusLabel and hiddenLabels at once, the callback could fire with a misleading toggle direction. Read directly from hiddenLabels instead, with optional chaining so the new path is a no-op when hiddenLabels is not provided. Behavior is unchanged for EventsChart (which does not use focusLabel today) but the controlled state is now the single source of truth. --- src/components/charts/Chart.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/charts/Chart.tsx b/src/components/charts/Chart.tsx index 5ac44273a..cd4410b68 100644 --- a/src/components/charts/Chart.tsx +++ b/src/components/charts/Chart.tsx @@ -70,7 +70,7 @@ export function Chart({ // and let the parent push a new hiddenLabels set on the next render. const { datasetIndex } = item; const ds = chart.current.data.datasets[datasetIndex]; - onLegendClick(ds.label, !ds.hidden); + onLegendClick(ds.label, !hiddenLabels?.has(ds.label)); return; }