[Feature] Focus strategy context: add the current focus and the trigger (`move`, `click`, `keyboard`)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 62/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- d3, typescript
- Área
- data-visualization
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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).
- Lenguaje dominante
- TypeScript
- Estrellas
- 870
- Forks
- 57
- Merge medio
- 11 h 58 min
- PR fusionados (30 d)
- 18
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TanStack/charts
-
[Perf] Canvas layer composition is quadratic: splitRenderLayers re-copies the node array per nodeAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
[Bug] Focus guides: `url(#id)` paints ignore `idPrefix`Posiblemente ocupada @getdownandcode la tomó hace 37 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
TanStack/charts#211 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Add reverse options to waffleY and waffleXPosiblemente ocupada @tannerlinsley la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 25/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
Los mantenedores suelen responder en 1 día
Todos los issues de TanStack/charts
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
fb55/htmlparser2#2579 ·
Los mantenedores suelen responder en 1 día
-
bug good first issue needs-review
Dificultad 1/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día
-
Add Module DB RulesAbiertodocumentation public
Dificultad 1/5 1-3 horas Aptitud para principiantes 68/100
midnightntwrk/umbradb#65 ·
Los mantenedores suelen responder en 2 días
-
area/channels kind/bug priority/medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
nanocoai/nanoclaw#4501 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Docker images: plain X.Y.Z tag (e.g. 7.2.3) is never updated after the initial release buildAbiertoneeds verification
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 13 días