[Bug] Focus ring invisible when the chart has an x viewport: clip-path <defs> gets visibility="hidden"
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 75/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- typescript
- Bereich
- accessibility, frontend
Rechercherichtung
Start by reading renderSvgClip in svg-renderer.js, then compare the focus visibility loops in motion.js and svg-surface.js. Reproduce with scales.x.viewport enabled and inspect how the focus layer's keyed defs element is handled. Done when the focus ring appears with a viewport and the clip region remains intact.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Version: @tanstack/charts 1.2.0, still present in 1.4.0
What happens
With scales.x.viewport set, the default focus ring on a lineY mark doesn't show on hover. The crosshair and tooltip work. The ring's <circle> is in the DOM with visibility="visible", but nothing is drawn.
Cause
With a viewport, the focus layer gets a clip path. renderSvgClip (svg-renderer.js) writes its <defs data-ts-key="…:clip-defs"> as a keyed child of the layer:
<g class="ts-chart__focus-layer" data-ts-focus-layer="over" clip-path="url(#…)">
<defs data-ts-key="default-focus:line-0:clip-defs" visibility="hidden">
<clipPath id="…"><rect x="44" y="4" width="700" height="178"/></clipPath>
</defs>
<circle data-ts-key="line-0:…" visibility="visible" … />
</g>
paintMotionSvgFocus (motion.js) and the same loop in svg-surface.js set visibility on every [data-ts-key] descendant of the layer, by whether its key is focused. The <defs> is never focused, so it gets hidden. The <rect> inside the clipPath inherits that. Per the SVG spec, a clip path child that isn't visible doesn't contribute to the clip, so the clip region is empty and the whole layer is clipped away.
Repro
defineChart({
marks: [lineY(data, { x: (d) => d.x, y: (d) => d.y }), crosshair({ x: true, y: false })],
scales: { x: { scale: scaleUtc, viewport: { domain: [from, to] } }, y: { scale: scaleLinear } },
focus: 'group-x',
})
Hover the plot: tooltip and crosshair appear, the ring doesn't. Remove viewport and the ring is back.
Suggested fix
Skip the clip definitions when painting focus visibility, e.g. leave out keys ending in :clip-defs or defs elements in the querySelectorAll("[data-ts-key]") loop. Alternatively, render the <defs> without a data-ts-key.
Workaround
[data-ts-focus-layer] > defs { visibility: visible; }
CSS outranks the presentation attribute.
Investigated with the help of an AI assistant; verified against the 1.2.0 and 1.4.0 dist.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 870
- Forks
- 57
- Ø Merge
- 11 Std. 58 Min.
- Gemergte PRs (30 T.)
- 18
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus TanStack/charts
-
[Perf] Canvas layer composition is quadratic: splitRenderLayers re-copies the node array per nodeOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
[Bug] Focus guides: `url(#id)` paints ignore `idPrefix`Evtl. vergeben @getdownandcode hat das vor 37 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
TanStack/charts#211 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Add reverse options to waffleY and waffleXEvtl. vergeben @tannerlinsley hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 25/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 55/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in TanStack/charts
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
fb55/htmlparser2#2579 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug good first issue needs-review
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 83/100
Maintainer antworten meist innerhalb von 1 Tag
-
Add Module DB RulesOffendocumentation public
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 68/100
midnightntwrk/umbradb#65 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
area/channels kind/bug priority/medium
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
nanocoai/nanoclaw#4501 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
needs verification
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 13 Tagen