Add role=list to lists to fix VoiceOver not announcing as lists #845
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
A recent accessibility audit found that when using VoiceOver on a do/don't list, that the list was not announced as a list. Further investgation found that this was a 'feature' of Safari and VoiceOver and that Apple regarded styling a list with
list-style-type: none
as an indication that the list is no longer a list as you are removing the default visible indication for a list. In our instance, we are restyling the list, so we might still expect it to be announced correctly, as it is with JAWS and NVDA. There is a good explanation of this here: https://www.scottohara.me/blog/2019/01/12/lists-and-safari.htmlThis issue has also been raised on govuk-frontend - alphagov/govuk-frontend#1471.
The suggested solution of adding
role=list
is probably the best fix, even if it doesn't seem quite right of adding a list role to a list element, which goes against the first rule of Using Aria.However in our case I believe this is justified as it could be argued that we are removing the semantics of the list via CSS, so we need to add it back in again via the
role
atrribute. And the fact that sighted users are seeing a list and JAWS and NVDA announce the list, then it makes sense to add this fix so there is consistent behaviour with VoiceOver.I've also added the fix to the error summary component. Other components such as the contents list or pagination don't seem to be affected.
I've tested this fix with the following:
Where the VoiceOvers announce the list correctly, and there is no change with NVDA, JAWS or Talkback.
Checklist