mathjax / MathJax

Beautiful and accessible math in all browsers
http://www.mathjax.org/
Apache License 2.0
10.23k stars 1.16k forks source link

semantic enrichment and keyboard focus to element with aria-hidden #3307

Open jmegginson opened 1 week ago

jmegginson commented 1 week ago

When semantic enrichment features of MathJax v4.0.0-beta.7 are enabled, programmatic focus gets set to a <g> element that is a child of <svg> with aria-hidden="true" set. When focus is set to an object that is a descendant of a node with aria-hidden="true" screen readers like JAWS and NVDA will not announce the focused object accurately (or at all).

It is observed that ARIA treeitemroles are set to these <g> tags. This could make sense to set focus to a treeitemonly if "Collapsible Math" is enabled but even then the aria-hidden property is set to trueon the parent SVG element currently.

To recreate you can add the following JS the Console in dev tools: document.addEventListener('focusin', function() { console.log('focused: ', document.activeElement) }, true);

With the Console open, navigate with the Tab key and observe that the child <g> elements gain focus when "semantic enrichment" is enabled: image console showing focused element

The elements panel will reveal that the parent node has aria-hidden="true" applied

image elements panel showing aria-hidden on parent container

Alternatively you can enable JAWS or NVDA and observe that nothing is announced (no ARIA treeitemroles or accessible labels) when navigating with virtual cursors or browse mode(s).

Note: When Semantic Enrichment is turned off, the <mjx-container> gains focus as expected.

It is suggested that programmatic focus remain on the <mjx-container> element like it does with MathJax v3.2.2. This way the aria-label (and any custom role) that is applied to this container can be conveyed and the various semantic enrichment features (speech and/or braille labels) can be announced.

Config:

zorkow commented 1 week ago

Thanks for the report. Some of the issues you mention are due to our current attempt to use the aria tree paradigm to "talk" to screenreaders rather than the old aria live region approach from v3. We are currently honing this and your feedback on future versions is very welcome.