[charts] Set aria-hidden on accessibility proxy divs at initialization#23186
Conversation
Deploy previewhttps://deploy-preview-23186--material-ui-x.netlify.app/Bundle size
PerformanceTotal duration: 1,783.37 ms +201.46 ms(+12.7%) | Renders: 63 (+0) | Paint: 2,553.17 ms +338.64 ms(+15.3%)
…and 13 more (+8 within noise) — details Metric alarms
…and 7 more metric alarms — details Check out the code infra dashboard for more information about this PR. |
fe5bc52 to
9e1aff6
Compare
|
Keeping this as a draft until a maintainer can add the |
mui#23185) The ChartsAccessibilityProxy creates two div[role="img"] elements whose aria-labelledby targets are empty until a chart item receives keyboard focus. Without aria-hidden, these divs appear in the accessibility tree as images with no accessible name, violating WCAG 1.1.1. Add aria-hidden="true" when the proxy divs are created. The existing focus handler already overrides this value correctly — setting aria-hidden="false" on the active div and "true" on the inactive div.
9e1aff6 to
24baf7e
Compare
|
@alexfauquette any input on this since you worked on it? Code looks good to me. Also how do you test this? MacOS voiceover doesn't seem to have this issue 🤔 |
@JCQuintas thank you for the quick reply! I agree live testing does not seem to cause any trouble, but static analysis tools (Access Assistant, AXE DevTools) both flag these divs as violations. For my project we're under strict commitments to fully comply with WCAG, and I am trying to remove as many warnings as I can, even if they are harmless
|
|
Thanks for the explanation. So that's not a bug, but a workaround to make static analysis tools happy :) |


Summary
Fixes #23185
ChartsAccessibilityProxycreates twodiv[role="img"]elements whosearia-labelledbytargets are empty until a chart item receives keyboard focus. Withoutaria-hidden, these divs appear in the accessibility tree as images with no accessible name, violating WCAG 1.1.1 (Non-text Content).Accessibility tools flag this as:
Changes
One-line fix: add
div.setAttribute('aria-hidden', 'true')when the proxy divs are created during initialization (line 59 ofChartsAccessibilityProxy.tsx).The existing focus handler already manages
aria-hiddencorrectly on subsequent interactions:activeDiv.setAttribute('aria-hidden', 'false')— reveals the active bufferinactiveDiv.setAttribute('aria-hidden', 'true')— hides the inactive bufferThe initial
aria-hidden="true"fills the gap between creation and first keyboard focus.Test plan
Added two browser tests in
ChartsAccessibilityProxy.test.tsx:aria-hidden="true"on initial render (before keyboard interaction)aria-hidden="false"is set on the active proxy div after keyboard navigationAll existing
useChartKeyboardNavigationtests pass (22/22).Reproduced on:
@mui/x-charts9.10.0 (latest) and 9.8.0.