[Bug] `motion()`: no enter animation for keyed rect/dot/text on first paint, or for marks in a newly joined group
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 42/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- d3, typescript
調査の方向性
Start with packages/charts-core/test-repro/08-motion-coverage.test.ts, run it with pnpm vitest run, and read the first-paint track setup in packages/charts-core/src/motion.ts near lines 281-286. The issue covers three separate gaps (first-paint enter for keyed rect/dot/text, numeric text tween in text.ts, and arc path morphing in polar.ts), so pick one and scope it. Done means the matching repro assertion passes without breaking the controls.
索引モデルが issue の本文から書いたものです。
説明
Version: @tanstack/charts 1.1.0 (57774e1).
Description
Two enter paths skip marks that the update path animates:
- A. Keyed
rect,dotandtextmarks get no enter track on first paint. - E. A mark group that joins during an update only fades; its per-datum enter (bar grow) never plays.
A. First paint: no enter track for keyed rect, dot, text
- First paint builds only bar, cartesian path, radial path and arc tracks (
motion.ts:281-286). - The generic enter track is added only for elements that join in an update (
motion.ts:2159). - Docs list only bars, paths and arcs for initial choreography (
motion.md:54-56).
Expected: keyed rect, dot and text get the same enter track on first paint as when they join a group, or the docs say initial covers only bars, paths and arcs.
Fix: call addEnterMotionTrack (motion.ts:2475) in the first-paint path for keyed elements no other track covers.
Repro: save as packages/charts-core/src/repro.test.ts, run pnpm vitest run packages/charts-core/src/repro.test.ts (vitest + jsdom, rAF driven by hand). "Animated" means the element has data-ts-motion-role. The test asserts the expected behaviour; the control passes.
import { expect, it, vi } from 'vitest'
import { scaleLinear } from 'd3-scale'
import { barY, defineChart, dot, rect, text } from './index'
import { motion } from './motion'
import { createChartScene } from './scene'
const queue: FrameRequestCallback[] = []
const tick = (t: number) => queue.splice(0).forEach((f) => f(t))
function mount() {
vi.spyOn(window, 'requestAnimationFrame').mockImplementation((f) => queue.push(f))
vi.spyOn(window, 'cancelAnimationFrame').mockImplementation(() => {})
const el = document.createElement('div')
const s = motion({ transition: { type: 'tween', duration: 1000, easing: 'linear' } }).mount(el, () => {})
return { el, render: (d: ReturnType<typeof defineChart>) =>
s.render(createChartScene(d, { width: 300, height: 200 }), { ariaLabel: 'x' }) }
}
const scales = { x: { scale: scaleLinear }, y: { scale: scaleLinear } }
const rows = [0, 1, 2].map((i) => ({ id: `r${i}`, x: i, x2: i + 0.5, y: 10 + i }))
const A = (data: typeof rows) => defineChart({ scales, guides: false, marks: [
barY(data, { key: 'id', x: 'x', y: 'y' }),
rect(data, { key: 'id', x1: 'x', x2: 'x2', y1: () => 0, y2: 'y' }),
dot(data, { key: 'id', x: 'x', y: 'y' }),
text(data, { key: 'id', x: 'x', y: 'y', text: 'y' }),
] })
const animated = (el: HTMLElement, sel: string) =>
[...el.querySelectorAll(`${sel} [data-ts-key]`)].filter((n) => n.hasAttribute('data-ts-motion-role')).length
const kinds = (el: HTMLElement) => ['bar', 'rect', 'dot', 'text'].map((k) => `${k}=${animated(el, `.ts-chart__${k}`)}`)
it('A: first paint animates keyed rect, dot and text like bars', () => {
const { el, render } = mount()
render(A(rows)); tick(0); tick(100)
expect(kinds(el)).toEqual(['bar=3', 'rect=3', 'dot=3', 'text=3'])
})
it('A control: the same marks join an empty chart with an enter track', () => {
const { el, render } = mount()
render(A([])); tick(0); tick(2000)
render(A(rows)); tick(0); tick(100)
expect(kinds(el)).toEqual(['bar=3', 'rect=3', 'dot=3', 'text=3'])
})
Output on 57774e14:
A: expected ['bar=3','rect=3','dot=3','text=3'], received ['bar=3','rect=0','dot=0','text=0']
A control: passes
Downstream measurement (bklit migration, Chrome, 800 ms window, keyed barY/lineY/rect/dot/text): first paint had 0 animating rects/dots/text; after an empty-then-data flip, 8/17 each.
E. A mark group that joins during an update only fades (from this comment)
In the update reconciler, an unmatched child is cloned and addEnterMotionTrack runs on that one element only (motion.ts:2140-2159). The function has no recursion into descendants. The bar grow branch requires the element itself to be a rect or path (motion.ts:1414-1420, motion.ts:2505-2510). So a bar joining an existing g.ts-chart__bar-y group grows, but a whole new group (a series that is added, or data that goes from [] to N rows so the mark group is new) falls to the opacity branch (motion.ts:2596-2635) and its bars never grow. createBarTracks runs only on first paint (motion.ts:273-286, motion.ts:1238).
Repro (source-level; not run): render a barY chart with [], then re-render with data. Expected a grow, observed a fade. Changing 0 to N on a chart whose group already exists does grow.
Proposal: when a group joins, run the first-paint enter tracks for its descendants (createBarTracks and friends scoped to the new group), so a joining group animates like a first paint.
B. Text content cannot be tweened
Moved to #215 (a new
textoption, with its repro).
C. Rounded polar arcs snap
Moved to #194, which covers arc motion, with its repro.
D. The only generic enter is an opacity fade (comment)
Moved to #214, together with the sunburst enter/exit seeds from #194 C.
- 主要言語
- TypeScript
- スター
- 870
- フォーク
- 57
- 平均マージ
- 11時間 58分
- マージ済み PR(30日)
- 18
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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
TanStack/charts#211 · コメント 1 件 ·
メンテナーはふだん 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 日以内に返信
TanStack/charts の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
fb55/htmlparser2#2579 ·
メンテナーはふだん 1 日以内に返信
-
bug good first issue needs-review
難易度 1/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 1 日以内に返信
-
Add Module DB Rulesオープン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 日以内に返信