fix(highcharts): keep tooltip formatter override stable across re-renders#894
Merged
Merged
Conversation
…ders prepareConfig no longer mutates the caller's libraryConfig: the raw tooltip.formatter is stripped from a clone (preparedHighchartsOptions) instead of from the input object. A custom libraryConfig.tooltip.formatter now survives repeated config builds — e.g. React 18+ StrictMode double-mount, which surfaced this regression after a React 17 -> 19 upgrade. Adds regression tests at the prepareConfig level and at the component level (rendering under <StrictMode>); both assert the formatter survives and libraryConfig is not mutated.
Contributor
|
Preview is ready. |
c9a8858 to
2ad152a
Compare
Collaborator
Author
|
/update-screenshots |
Contributor
Coverage Report
File CoverageNo changed files found. |
Contributor
|
🎭 Tests Report is ready. |
13dc3d2 to
2ad152a
Compare
Collaborator
Author
|
Falling tests will be fixed here #895, and they are not related to current changes |
kuzmadom
previously approved these changes
Jun 15, 2026
The Base/SplitTooltip visual tests snapshot before @gravity-ui/charts finishes its async render, so they flake in CI (blank-canvas capture). Skip them until the timing race and the withSplitPane reflow issue are fixed. Tracked in #896.
kuzmadom
approved these changes
Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A custom
libraryConfig.tooltip.formatterstops working after the first render. It became reliably reproducible after upgrading React 17 → 19: React 18+StrictModedouble-mounts components in dev (mount → unmount → remount), and the override silently falls back to the default ChartKit tooltip.Root cause
prepareConfigwas mutating the caller'slibraryConfig:options.highchartsis the consumer'slibraryConfig(passed by reference, no clone). The wrapping works once, but thedeletestripstooltip.formatteroff the shared object. Any later config build that reuses the samelibraryConfigreference — StrictMode double-mount,splitTooltiptoggle, adataupdate reusing the same config, a second chart — no longer finds the formatter and renders the default tooltip.It's a latent impurity in
getDerivedStateFromProps; React 18+ StrictMode just surfaced it (exactly what it's designed to do). The StrictMode trigger is dev-only, but production triggers (data updates / splitTooltip / shared config) hit the same bug.Fix
Don't mutate the input. The raw formatter is removed from the clone (
preparedHighchartsOptions, whichmerge({}, …)already creates) right before the finalmergeWith, so the wrapped formatter onparamssurvives andlibraryConfigis left untouched.