[charts][accessibility] Fix keyboard navigation on series with different lengths#23182
Conversation
Deploy previewhttps://deploy-preview-23182--material-ui-x.netlify.app/Bundle size
PerformanceTotal duration: 1,703.29 ms +227.65 ms(+15.4%) | Renders: 63 (+0) | Paint: 2,432.90 ms +386.48 ms(+18.9%)
…and 7 more (+14 within noise) — details Metric alarms
…and 6 more metric alarms — details Check out the code infra dashboard for more information about this PR. |
alexfauquette
left a comment
There was a problem hiding this comment.
Might be safer to modify the default value of useCurrentSeriesMaxLength to true to avoid crashes
| describe('findVisibleDataIndex', () => { | ||
| it('does not return an index outside the focused series', () => { | ||
| it('returns an index beyond the focused series length when `dataLength` allows it', () => { | ||
| // Shared-axis types (line, bar) navigate over the longest compatible series. |
There was a problem hiding this comment.
Why not keeping the previous test for the scatter chart?
There was a problem hiding this comment.
This specific function doesnt' know about series length capping anymore.
This is done mostly by the props passed into createCommonKeyboardFocusHandler which then provides it to the getNextIndexFocusedItem & family functions.
I believe you added this as a feature for the maps, but it can be reused for our use-case here.
Follow-up to #23180, addressing #23180 (comment).
#23180 capped keyboard navigation at the focused series length inside
findVisibleDataIndex. That broke shared-axis series (line, bar) of different lengths, where focusing an index with no value is expected so navigation stays consistent across series sharing the same x-axis.This PR restores the previous
findVisibleDataIndexbehavior (navigation range is defined by the caller) and moves the cap to the series-type level via the existinguseCurrentSeriesMaxLengthoption. Following the review feedback, the option now defaults totrueso series types are crash-safe by default:scatter(keeps the fix for [charts] Crash when navigating out of bounds with Arrow Right #23179),pie,funnel,map— capped at the focused series length (default)line,bar,rangeBar,radialBar,radialLine,radar— explicitly opt out to keep the max-length navigation rangeAdditionally, funnel read
dataPoints[dataIndex]/data[dataIndex]unguarded inFocusedFunnelSection, the tooltip position selector, and the tooltip getter, crashing on a stale focused index (e.g. data shrank while a section was focused, which the navigation cap cannot prevent). These now bail out like the line/pie equivalents do.