Conversation
Add `maidr/victory` entry point with `<MaidrVictory>` React component that wraps Victory chart components and automatically provides accessible non-visual access through audio sonification, text descriptions, braille output, and keyboard navigation. Supports VictoryBar, VictoryLine, VictoryScatter, VictoryArea, and VictoryPie chart types with automatic data extraction from component props and SVG element tagging for highlight integration. Closes #543 https://claude.ai/code/session_01EWLKfgUPQxmnWhB78rrkYg
Code Review: feat: add Victory charting library supportGood addition of Victory charting library support. The architecture is sensible — a separate entry point with an adapter layer, keeping Victory concerns isolated from the core. Here are the issues I found, roughly ordered by severity. Bugs1.
Add a 2.
If there is no Type Safety3.
The actual shape produced by Fragility / Correctness Concerns4. DOM selector strategy relies on Victory internal structure
5. Line/area path heuristic is fragile
6.
7. Children introspection breaks with HOCs and wrappers
Performance8.
Unsupported Patterns (Documentation Gap)9.
Tests10. No tests included There are no tests for the new Victory adapter. Given the adapter relies on React children introspection, DOM manipulation, and multi-step heuristics, it is both the most testable and most breakage-prone part of this PR. Unit tests for Minor
Overall this is a useful feature addition with clean separation of concerns. The main actionable items before merge are the implicit |
Addresses all review feedback from PR #558: - Fix missing default case in toMaidrLayer by using discriminated union on VictoryLayerData (kind field) so the switch is exhaustive - Replace `unknown` data typing with discriminated union for type safety - Memoize extractVictoryLayers with useMemo to prevent useLayoutEffect from re-running on every parent re-render - Improve HOC resilience by traversing WrappedComponent, render, and type properties when resolving Victory displayName Add support for all MAIDR trace types that have Victory equivalents: - VictoryBoxPlot → TraceType.BOX - VictoryCandlestick → TraceType.CANDLESTICK - VictoryHistogram → TraceType.HISTOGRAM (with client-side binning) - VictoryGroup → TraceType.DODGED (grouped bar charts) - VictoryStack → TraceType.STACKED (stacked bar charts) https://claude.ai/code/session_01EWLKfgUPQxmnWhB78rrkYg
PR Review: feat: add Victory charting library supportGreat feature addition! The architecture is well thought-out — using a separate entry point, an adapter layer, and graceful degradation when selectors can't be found are all good patterns. Here are some issues worth addressing before merge. Bugs1.
function validateRawData(rawData: unknown): rawData is Record<string, unknown>[] {
return Array.isArray(rawData) && rawData.length > 0 && typeof rawData[0] === 'object';
// ^^^^ null passes this check
}The guard should be: typeof rawData[0] === 'object' && rawData[0] \!== null2. Tagged DOM attributes accumulate on re-renders (selectors.ts:86-88) When 3. Empty chart loses title/subtitle/caption (MaidrVictory.tsx:170) if (\!container || victoryLayers.length === 0) return; // early returnIf Victory renders a chart with no supported layer types, the 4. Stack overflow risk with large histograms (adapter.ts:473-474) const min = Math.min(...values);
const max = Math.max(...values);
Design/Robustness Concerns5. Fragile DOM selector strategy (selectors.ts) The entire highlighting mechanism relies on Victory always rendering data elements with 6. Fragile line/area path heuristic (selectors.ts:115-123) The path selection logic counts SVG path commands and compares to
The fallback exists but means the wrong path element gets tagged silently. 7. VictoryPie → BAR semantic mismatch (adapter.ts:521-523, index.ts comment) Mapping
8. const victoryLayers = useMemo(() => extractVictoryLayers(children), [children]);React creates a new Missing Coverage9. No tests None of the new modules have test coverage. The following are particularly high-value to test since they're pure functions:
Minor10. Pie slices in Victory are rendered as 11. legend: victoryLayers.find(l => l.legend)?.legend,If a chart has multiple Overall this is a solid implementation with good separation of concerns. The main blockers are the |
- Fix validateRawData null check (typeof null === 'object' passes) - Fix stack overflow in histogram Math.min/max(...values) on large arrays - Fix stale DOM attributes: clean up old data-maidr-victory-* on re-render - Fix empty chart losing metadata: preserve title/subtitle/caption - Fix children useMemo instability: use fingerprint-based comparison - Fix legend collection: gather legends from all layers, not just first - Add VictoryPie selector comment clarifying path vs rect grouping - Add @remarks documenting Victory v37 DOM structure dependency - Fix ESLint formatting issues https://claude.ai/code/session_01EWLKfgUPQxmnWhB78rrkYg
PR Review: feat: add Victory charting library supportGreat addition — making MAIDR work with Victory enables a much wider audience of React developers to build accessible charts. The architecture (separate entry point, optional peer dep, fingerprint-based skip) is well-thought-out. Issues found are ordered by severity. Bug: Metadata props silently fail to updateFile: The fingerprint only hashes layer data ( Fix: Include metadata in the fingerprint string, or add a separate
|
| Severity | Issue |
|---|---|
| Critical | Metadata props (id, title, subtitle, caption) silently fail to update when chart data is unchanged |
| Critical | clearTaggedElements hardcoded to 10 layers; silent failure for larger charts |
| Major | Histogram bin count mismatch when bins is an array |
| Major | process.env: {} stub can cause runtime issues |
| Major | HOC traversal has no cycle guard (potential infinite recursion) |
| Minor | Unsafe type casts; missing dep-array comment; missing warn log for failed selectors |
The overall design is solid and the graceful degradation story for highlighting is correct. The two critical bugs should be fixed before merge.
Add
maidr/victoryentry point with<MaidrVictory>React componentthat wraps Victory chart components and automatically provides accessible
non-visual access through audio sonification, text descriptions, braille
output, and keyboard navigation.
Supports VictoryBar, VictoryLine, VictoryScatter, VictoryArea, and
VictoryPie chart types with automatic data extraction from component
props and SVG element tagging for highlight integration.
Closes #543
https://claude.ai/code/session_01EWLKfgUPQxmnWhB78rrkYg