Repository navigation
fix(charts): scope focus guide gradient paints with idPrefix - #217
getdownandcode wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Create hooks and wire the SVG surface packages/charts-core/src/svg-focus-guide-layer.ts, packages/charts-core/src/svg-surface.ts, packages/charts-core/src/svg-surface.test.ts, .changeset/focus-guide-id-prefix-paint.md |
The hook factory rewrites matching gradient references with a sanitized idPrefix. The SVG surface passes the hooks to the default focus-guide renderer. The test checks a prefixed crosshair gradient reference. |
Pass hooks through motion rendering packages/charts-core/src/motion.ts, packages/charts-core/src/motion.test.ts |
The motion renderer creates and passes hooks during scene rendering and focus painting. The test checks that a focus-guide stroke uses the prefixed gradient ID. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
- Issue 191 — The change addresses its focus-guide paint-scoping portion. Its gradient-stop and
gradientUnitsrequirements remain separate.
Suggested reviewers: tannerlinsley
Merge Risk: 
Minimal · up to 3046b
-
No actionable merge-blocking risk is established in this change.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Linked Issues check
-
Explanation
Issue
#211requires guide and crosshair paints that use url(#id) to resolve to the idPrefix-scoped gradient id, matching mark paints. The head adds createFocusGuideRenderHooks(scene) in svg-focus-guide-layer.ts. It rewrites url(#id) only when id is in scene.gradients. It sanitizes idPrefix with the same rule that renderChartSvg uses in svg.ts (remove characters outside [a-zA-Z0-9_-]), so guide and mark ids match. svg-surface.ts and motion.ts create these hooks on each scene update and pass them to renderFocusGuideLayer in the default SVG path. The reported tests cover a crosshair stroke that resolves to url(#a-fade) and a sanitized prefix case. Pattern resources are described in#211as future work after PR#166, so their absence is not an unmet requirement. Residual uncertainty: the renderer-based guide path (renderFocusGuideLayerWithRenderer) is not changed. The source evidence does not show whether that path already scopes paints through the supplied renderer. The reported tests and maintainer checks cover both renderers, but the test files were not executed in this review.
Full details: Out of Scope Changes check
-
Explanation
The source changes connect directly to
#211. createFocusGuideRenderHooks, the hook wiring in svg-surface.ts and motion.ts, and the regression tests in svg-surface.test.ts and motion.test.ts all implement or verify the scoped focus-guide paint behavior. The changeset documents the fix. Static SVG document rendering (svg.ts, svg-renderer.ts) is not changed, as the PR description states. The PR description also reports updates to universal-baseline.json and 7 bundle ceilings in scripts/measure-bundles.mjs for the helper cost. Those files do not appear in the file-level change summary, so their presence at head was not verified. If present, they are tied to the new helper, but the maintainer states that bundle-limit increases are a separate approval gate. Those bundle-limit changes should be reported separately from this fix and are not evaluated as a product behavior change here.
-
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
🦋 Changeset detectedLatest commit: 3046be0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Thanks @getdownandcode, I verified the gradient fix at ae1703f. All 72 cases passed in Chromium, Firefox and WebKit, covering both SVG renderers, sanitized prefixes, gradient removal and re-addition, marker fills, and unrelated paint references. The same checks reproduce 12 failures per browser on main. The remaining concern is bundle cost. A paired check of the changed runtime files across 114 entry points found increases up to 0.095 kB gzip and 0.096 kB Brotli. This is a targeted check, not the full repository validation. The proposed budget increases still need approval before merging. I also tried sharing the existing SVG paint resolver. That reduced the maximum gzip increase to 0.048 kB, but affected more entry points and increased the worst Brotli delta to 0.114 kB, so I haven't applied that experiment to your PR. Keeping #211 open until the fix clears the remaining checks and lands. |
|
@tannerlinsley Thanks for verifying the tests and bundle size! Glad all 72 cases passed. I'll let the remaining checks finish—let me know if you need any other changes before this lands. |
|
Thanks @getdownandcode, the isolated checkout and package checks below are complete at ae1703f. All 2,214 unit tests and 23 tests across the six additional framework configurations pass, along with TypeScript and the docs contract. The packed-package gate also passes, including bare React Native, Expo, seven adapters and the unified artifact. I reran the 72 focus-guide cases against the final packed exports in Chromium, Firefox and WebKit. All pass, covering sanitized prefixes, gradient removal and re-addition, marker fills and unrelated paint references. The negative control fails as expected. The bundle check passes against this PR’s proposed limits, but that does not approve those increases. The budget decision and required CI remain separate gates, so #211 stays open until the fix lands. No limits were changed during this verification. Remaining repository checks: the catalog-preview fingerprint is stale at this head. I rendered all 188 cases in both themes from the isolated production build and regenerated their portable SVGs. Every SVG is byte-identical to the committed asset, so only manifest sourceHash needs to become Verified head: |
|
Makes total sense on keeping the budget decision as a separate gate. Really appreciate you running such thorough checks across the full test suite and packed exports. @tannerlinsley, Happy to hold tight until the team signs off on it. |
|
Hey @tannerlinsley, noticed some recent merges on main touched the bundle baselines. Let me know if you'd like me to rebase onto latest main! |
|
Thanks @getdownandcode, yes please rebase onto current main. Keep the fix scoped to the focus-guide paints, and report any bundle-limit changes separately so we can review the remaining cost against the new base. The earlier budget and CI holds still apply. |
Scope focus guide and crosshair url(#id) gradient paint references when an idPrefix is configured on both static SVG and motion surfaces. Fixes TanStack#211
ae1703f to
3046be0
Compare
|
@tannerlinsley Rebased onto current Here is the measured bundle delta against the new base: Locked Universal Baselines:
Derivative Entry Point Ceilings:
Static SVG document rendering ( |
Fixes #211
What changed & why
When a chart is configured with
idPrefix,<defs>gradients are scoped (e.g.<linearGradient id="chart-a-fade">), andrenderChartSvgrewrites mark paints viaresolvePaint. However, transient focus guides rendered viarenderFocusGuideLayerused default hooks withoutresolvePaint, leavingurl(#id)references unprefixed on hover:Changes
createFocusGuideRenderHooks(scene)insvg-focus-guide-layer.tsto scopeurl(#id)paints againstscene.gradients(returnsundefinedwhen the scene has no gradients).svg-surface.tsandmotion.tsso noSetor closure allocations happen during high-frequency pointer hover events.svg.ts/svg-renderer.ts) untouched, preserving isolated static SVG bundle boundaries.universal-baseline.jsonand adjusted 7 derivative bundle ceilings inscripts/measure-bundles.mjsto reflect the small helper cost (~70 B gzip on DOM host).svg-surface.test.tsandmotion.test.ts.@tanstack/charts.Validation output
Summary by CodeRabbit