[Feature] Focus strategy context: add the current focus and the trigger (`move`, `click`, `keyboard`)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 62/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- d3, typescript
- Ambito
- data-visualization
Direzione di ricerca
Start with the ChartFocusResolveContext type in packages/charts-core/src/types.ts (around line 2113), then the context built in packages/charts-core/src/interaction.ts (line 68) and the focusedPoint field in renderer.ts (line 135). Add an optional current array filled from the focused points, and update docs/reference/focus-and-interaction.md near line 771. Done when the repro test packages/charts-core/test-repro/05-pointer-focus.test.ts passes and the context type and docs describe current.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Version: @tanstack/charts 1.1.0 (57774e1).
A ChartFocusStrategy.resolve gets only (points, { x, y, maxDistance }). It cannot know which points are focused (A), so a custom strategy cannot keep a sticky hit area, for example when a focused mark grows and the pointer sits on its old edge. It also cannot tell a pointer move from a click (B). Both are additive fields on the same context.
A. No current focus in the context
- The context type has only
x,y,maxDistance: types.ts:2113-2117. Documented the same way: focus-and-interaction.md:771. - The renderer tracks
focusedPoint(renderer.ts:135) but does not pass it: interaction.ts:68. resolveis re-run on every presentation publish (renderer.ts:1232-1240), so closure state in a strategy cannot track focus reliably.
Repro: save as packages/charts-core/src/repro.test.ts, run pnpm vitest run packages/charts-core/src/repro.test.ts.
import { expect, it, vi } from 'vitest'
import { scaleLinear } from 'd3-scale'
import { dot } from './dot'
import { motion } from './motion'
import { mountChartRenderer } from './renderer'
import { defineChart } from './scene'
import type { ChartFocusResolveContext } from './types'
it('A: a focus strategy is told which points are currently focused', () => {
const seen: ChartFocusResolveContext[] = []
const rows = [{ x: 1, y: 1 }, { x: 2, y: 2 }]
const container = document.createElement('div')
const host = mountChartRenderer(container, {
definition: defineChart({
marks: [dot(rows, { x: 'x', y: 'y' })],
scales: { x: { scale: scaleLinear }, y: { scale: scaleLinear } },
pointer: false,
focus: {
resolve: (points, context) => (seen.push(context), points.slice(0, 1)),
group: (_points, { point }) => [point],
navigation: (points) => points,
},
}),
renderer: motion({ initial: false }),
width: 300, height: 200, ariaLabel: 'Dots',
})
vi.spyOn(container.querySelector('svg')!, 'getBoundingClientRect').mockReturnValue(
DOMRect.fromRect({ width: 300, height: 200 }),
)
host.interaction.setControlledFocus(host.interaction.resolvePointer(10, 10))
host.interaction.resolvePointer(11, 11) // second call, a point is now focused
expect(seen.at(-1)).toHaveProperty('current')
})
Output on 57774e1: AssertionError: expected { x: 11, y: 11, maxDistance: 48 } to have property "current".
Downstream (bklit migration, Chrome, arc that scales up when focused): focus toggled on and off at the arc's inner edge as it grew and shrank.
B. No trigger in the context (from this comment)
A pointer move and a click both reach strategy.resolve through pointsAtPointer (renderer.ts:644; callers renderer.ts:752 and renderer.ts:858), so a strategy cannot treat them differently.
Example: a sunburst keeps hover on the last sector while the pointer is over the hub or a gap, but a click on the hub must still zoom out and a click on a gap must do nothing. Holding the focus inside resolve would also hold the hub click, because the click re-resolves through the same function. The only workaround is capture-phase pointermove and click listeners on the host.
Proposed
Add two optional fields to ChartFocusResolveContext, filled by the renderer:
current?: readonly ChartPoint<TDatum, TXValue, TYValue>[], the focused points;kind?: 'move' | 'click' | 'keyboard', the trigger.
The second part of the comment (the pointer position in
onFocusChange) moved to #207, which asks for the focus position on the host.
Related: #203 (pointer move cost).
- Lingua principale
- TypeScript
- Stelle
- 870
- Fork
- 57
- Merge medio
- 11h 58m
- PR unite (30g)
- 18
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TanStack/charts
-
[Perf] Canvas layer composition is quadratic: splitRenderLayers re-copies the node array per nodeAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug] Focus guides: `url(#id)` paints ignore `idPrefix`Forse già presa @getdownandcode l’ha presa 37 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
TanStack/charts#211 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Add reverse options to waffleY and waffleXForse già presa @tannerlinsley l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 25/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di TanStack/charts
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
fb55/htmlparser2#2579 ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue needs-review
Difficoltà 1/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno
-
Add Module DB RulesApertadocumentation public
Difficoltà 1/5 1-3 ore Idoneità per principianti 68/100
midnightntwrk/umbradb#65 ·
I maintainer di solito rispondono entro 2 giorni
-
area/channels kind/bug priority/medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
nanocoai/nanoclaw#4501 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
needs verification
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 13 giorni