question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Radio controls component has accessibility issues

See original GitHub issue

The radio controls component has several accessibility issues. I thought it was easier to lump them all together for the single component rather than separate issues for each.

I threw together a test page https://stommepoes.nl/work/shoelace/shoelace_demo.html and, on Windows only, ran 2 screen readers (NVDA latest, JAWS 2019) on 3 browsers (Edge latest, Chrome latest, Firefox latest… as of 23 September 2020). I don’t own any iThings or I would have run VoiceOver on Safari (this is the combination for MacOS that is preferred for testing) as well.

  • The docs show a single radio control as an example of the component. While there is some logical sense in showing this, developers using this library may not realise radios cannot be used singley.
  • The grouped radios example simply has several individual radio controls placed together, sharing a name attribute. However, radio controls must be within a radiogroup element (such as a <fieldset> which has this role natively, or an element with a manually-added radiogroup ARIA role).
  • Since there is not an example of radio controls within a radiogroup, it is unclear (if impossible?) to assign a name to the radiogroup. For example, in a form which asks a question where each radio’s label exposes a possible option, the question is the “name” of the radiogroup. In native HTML, this is a <legend>, which must be the first child of a <fieldset>. With non-native elements, this might be an element with a unique id, and the element with the radiogroup role is named by having aria-labelledby pointing to that id.
  • For reasons I could not determine, in Firefox each radio control was announced as being “1 of 1” (instead of “1 of [total]”). In Chrome, there was no announcement of placement either way. I suspect adding a radiogroup would fix this but not 100% certain.
  • In Firefox only, each of the radio controls could be Tabbed to with the Tab key, instead of the entire radio group acting as a single Tab stop. ** A note about Firefox: I tested a native set of ungrouped and a native set of grouped radio controls, to see if it was the lack of grouping causing the Tab issue. In Firefox, the grouping (or lack thereof) seems to have no direct effect. Firefox seems to allow Tabbing to each radio so long as none of them are selected. Once a selection is made, the typical native keyboard behaviour occurs. Yet in the tested Shoelace version, while there appears to always be at least one pre-selected radio, even manually mouse-clicking or using Enter to select a particular control does not bring the required “1 Tab stop per radio group” behaviour on the Shoelace radios.

It is expected that

  • radio controls are only ever shown in radiogroups, even in documentation.
  • radiogroups can (must) be named.
  • announce their position-in-set (“one of four, two of four,” etc)
  • are treated as a single Tab stop, with the possible exception of in Firefox when there is no default selection.

Desktop:

  • OS: Windows 10
  • Browsers: Edge latest, Chrome latest, Firefox latest (as of 23 September 2020)
  • Screen readers: NVDA latest, JAWS 2019

Note: Bug #215 is also applicable

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
claviskacommented, May 24, 2022

Interestingly, Firefox + VoiceOver doesn’t read the labels but it does announce twice as many radios. This also seems like a browser bug to me, but adding aria-hidden="true" to the internal radio input seems to alleviate it without any ill effects on Chrome and Safari.

I’ll try to look into this more soon. Thanks so much for the detailed info!

0reactions
claviskacommented, Aug 4, 2022

Radios have been refactored in #833 and #847 to solve all known remaining issues. 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Complete Guide To Accessible Front-End Components
An up-to-date collection of accessible front-end components: accordions, form styles, dark mode, data charts, date pickers, form styles, ...
Read more >
Radio buttons | Introduction to Accessibility
To make radio buttons accessible you should use a label. Here you will an idea of how screen readers will read out different...
Read more >
Short note on the accessibility of styled form controls - TPGi
Though the issue with native form controls is that they have an infamous reputation for being problematic to style.
Read more >
Grouping Controls | Web Accessibility Initiative (WAI) - W3C
Grouping related form controls makes forms more understandable for all users, as related controls are easier to identify. It also makes it easier...
Read more >
Handling common accessibility problems - MDN Web Docs
Next, you have to open your Mac's System Preferences app, then go to Keyboard > Shortcuts, then select the All Controls radio button....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found