Files
superset2/superset-frontend
Claude e8f20a67e4 fix(AnnotationLayer): stop double-fetching chart on hydration + drop dead useCallback
Two fixes from @sadpandajoe's review.

1. **Double-fetch.** `fetchAppliedChart` synchronously sets both `value`
   and `slice` from one API response. The value-change watcher then saw
   `value` changed and called `fetchSliceData(value.value)` — re-resolving
   the same chart and overwriting the slice we just set.

   Fix: gate the watcher's `fetchSliceData` on `!slice`. When
   `fetchAppliedChart` populated slice in lockstep, the gate skips. When
   the user selects a different chart from the dropdown
   (`handleSelectValue`), `slice` is now cleared to null first, so the
   watcher fires and fetches correctly.

2. **Dead `useCallback`.** `renderChartHeader` (empty deps) only built
   JSX from its arguments and was called inline as `renderChartHeader(…)`
   — neither the produced node nor the function identity was observed by
   a memoized consumer, so the useCallback was overhead with no benefit.
   Inline as a plain helper named `buildChartHeader`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 14:31:29 -07:00
..
2026-05-04 19:19:36 +03:00