[Bug] Focus ring invisible when the chart has an x viewport: clip-path <defs> gets visibility="hidden"
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 75/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- TypeScript
- 星标
- 870
- 派生
- 57
- 平均合并
- 11 小时 58 分钟
- 30 天内合并 PR
- 18
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/charts 的其他 Issue
-
[Perf] Canvas layer composition is quadratic: splitRenderLayers re-copies the node array per node未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
[Bug] Focus guides: `url(#id)` paints ignore `idPrefix`可能已有人在做 @getdownandcode 于 37 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
Add reverse options to waffleY and waffleX可能已有人在做 @tannerlinsley 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 25/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
fb55/htmlparser2#2579 ·
维护者通常 1 天内回复
-
bug good first issue needs-review
难度 1/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
documentation public
难度 1/5 1-3 小时 新手友好度 68/100
midnightntwrk/umbradb#65 ·
维护者通常 2 天内回复
-
area/channels kind/bug priority/medium
难度 2/5 1-3 小时 新手友好度 78/100
nanocoai/nanoclaw#4501 · 1 条评论 ·
维护者通常 1 天内回复
-
needs verification
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 13 天内回复