Skip to content

[charts][accessibility] Fix keyboard navigation on series with different lengths#23182

Merged
JCQuintas merged 6 commits into
mui:masterfrom
JCQuintas:fix/charts-keyboard-nav-line-series
Jul 20, 2026
Merged

[charts][accessibility] Fix keyboard navigation on series with different lengths#23182
JCQuintas merged 6 commits into
mui:masterfrom
JCQuintas:fix/charts-keyboard-nav-line-series

Conversation

@JCQuintas

@JCQuintas JCQuintas commented Jul 20, 2026

Copy link
Copy Markdown
Member

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 findVisibleDataIndex behavior (navigation range is defined by the caller) and moves the cap to the series-type level via the existing useCurrentSeriesMaxLength option. Following the review feedback, the option now defaults to true so series types are crash-safe by default:

Additionally, funnel read dataPoints[dataIndex]/data[dataIndex] unguarded in FocusedFunnelSection, 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.

@JCQuintas JCQuintas added accessibility a11y plan: Pro Impact at least one Pro user. type: regression A bug, but worse, it used to behave as expected. scope: charts Changes related to the charts. labels Jul 20, 2026
@JCQuintas JCQuintas self-assigned this Jul 20, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Jul 20, 2026

Copy link
Copy Markdown

Deploy preview

https://deploy-preview-23182--material-ui-x.netlify.app/
QR code for https://deploy-preview-23182--material-ui-x.netlify.app/

Bundle size

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts ▼-18B(0.00%) ▼-3B(0.00%)
@mui/x-charts-pro 🔺+46B(+0.01%) 🔺+14B(+0.01%)
@mui/x-charts-premium 🔺+64B(+0.01%) 🔺+21B(+0.01%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)
@mui/x-scheduler 0B(0.00%) 0B(0.00%)
@mui/x-scheduler-premium 0B(0.00%) 0B(0.00%)
@mui/x-chat 0B(0.00%) 0B(0.00%)
@mui/x-license 0B(0.00%) 0B(0.00%)

Details of bundle changes

Performance

Total duration: 1,703.29 ms +227.65 ms(+15.4%) | Renders: 63 (+0) | Paint: 2,432.90 ms +386.48 ms(+18.9%)

Test Duration Renders
SparkLineChart grid of 100 instances 133.92 ms 🔺+39.63 ms(+42.0%) 1 (+0)
BarChart stacked with multiple series 98.27 ms 🔺+33.43 ms(+51.6%) 2 (+0)
CandlestickChart with big data amount (webgl renderer) 144.04 ms 🔺+26.48 ms(+22.5%) 5 (+0)
ScatterChartPro with big data amount (batch renderer) 20.44 ms 🔺+12.57 ms(+159.6%) 2 (+0)
ScatterChart with big data amount 33.10 ms 🔺+11.18 ms(+51.0%) 2 (+0)

…and 7 more (+14 within noise) — details

Metric alarms

Test Metric Change
SparkLineChart grid of 100 instances bench:paint 🔺 +144.48 ms
BarChart stacked with multiple series bench:paint 🔺 +50.28 ms
CandlestickChart with big data amount (webgl renderer) bench:paint 🔺 +26.94 ms
ScatterChartPro with big data amount (batch renderer) bench:paint 🔺 +18.62 ms
ScatterChart with big data amount bench:paint 🔺 +15.92 ms

…and 6 more metric alarms — details


Check out the code infra dashboard for more information about this PR.

@JCQuintas
JCQuintas marked this pull request as ready for review July 20, 2026 09:49
@JCQuintas
JCQuintas requested a review from alexfauquette as a code owner July 20, 2026 09:49
@JCQuintas
JCQuintas requested a review from silviuaavram July 20, 2026 09:49

@alexfauquette alexfauquette left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keeping the previous test for the scatter chart?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@JCQuintas JCQuintas added the plan: Premium Impact at least one Premium user. label Jul 20, 2026

@alexfauquette alexfauquette left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@JCQuintas
JCQuintas merged commit 8f81a1e into mui:master Jul 20, 2026
22 checks passed
@JCQuintas
JCQuintas deleted the fix/charts-keyboard-nav-line-series branch July 20, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility a11y plan: Premium Impact at least one Premium user. plan: Pro Impact at least one Pro user. scope: charts Changes related to the charts. type: regression A bug, but worse, it used to behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants