Problem/Motivation
The readability of forms by screen readers greatly improves with descriptive markup and structure. One way to do this, which is used for some groups of checkboxes and radio buttons, is through fieldsets. This gives the screen reader a label for the group (the legend) and tells the user how many elements are contained within the group. I believe this fits within the WCAG2.0 AA compliant goals of D8.
There are alternative approaches to giving screen readers this information. This bug captures one approach that relies on aria-describedby and aria-labeledby elements: https://www.drupal.org/project/drupal/issues/2896225
To compare the information given with and without fieldset formatting:
* Go to /node/add/article
* Turn on your computer's screen reader
* Navigate to Comment settings section (radio buttons contained within a fieldset)
* Navigate to the Promotion Options settings section (checkboxes not contained within a fieldset)
Proposed resolution
Since the use of fieldsets is already partially implemented (see CompositeFormElementTrait.php), I think it would make sense to expand this approach to groups of checkboxes or radio buttons more consistently.
Issue fork drupal-2951714
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
mgiffordThis would be good https://www.w3.org/WAI/tutorials/forms/grouping/
Comment #3
jrockowitz commented@mgifford After reading that page it seems like the PasswordConfirm element, which contains two password elements, should also be considered a 'Grouping Controls' and wrapped in a fieldset with a legend.
Comment #4
mgiffordThat makes sense to me @jrockowitz
Comment #14
larowlanIs this a bug? It feels like a task
Comment #15
mgiffordLooks like a WCAG 1.3.1 issue so tagging.
Comment #18
acbramley commentedI don't think this is something that can be fixed generically, we'd need to fix each instance of these separately.
For example, the IS talks about the Promotion options on the node form. This is 2 boolean base fields, rendered as checkboxes via their widgets and then wrapped in a details element via
NodeForm::formAre there other specific examples we can target?
Comment #20
smustgrave commentedSince this is accessibility wanted to bump 1 more time for answer to #18
Comment #21
smustgrave commentedSince there's been no follow up going to close out. It can always be re-opened but would be good to address #18 please.
Thanks all.