In the Minerva skin, sections are collapsed by default on mobile devices, however, this information is not conveyed to screen-readers. When tabbing through sections, all that people using a screen-reader hear is the name of the section, with no indication that the section is collapsed and can be expanded to reveal more content.
Compare the current behaviour to another website like apple.com, where the collapsed sections are announced to screen-readers (on Safari, MacOS desktop)
|Demo video||Collapsed state||expanded state|
|m.wikipedia.org demo video||Heading level 2 heading name, clickable||press heading level 2, heading name|
|apple.com demo video||heading name, collapsed, button||heading name, expanded, button|
Note that screen-readers vary widely in their verbosity level and what is read aloud.
On iOS for example, section headings are read as:
"heading name, Heading level 2, table start" and then "Edit, Heading level 2, link, table end"
The headings are not inside a table, but they’re interpreted as such because display: table; is used in the CSS. The word “clickable” is also omitted on iOS, which leaves no indication that the heading contains any content. Announcing the CSS table might be a bug in Safari, but it might still be worth replacing the display:table layout with something more… flexible 😉
ARIA attribute changes
- Remove the erroneously placed aria-expanded attribute from the section content, which exists in Toggler.js#153. Added in c8d446be9164 in 2013.
- Remove the aria-pressed attribute. This is meant for toggle-buttons like checkboxes or radios.
- Remove the aria-haspopup="true" (meant for modals or popup-menus) from the section heading. The aria-expanded should suffice.
- Add the aria-expanded="true/false" attribute to the section heading.
The heading should be announced as a button, but if we add role=button then the heading might loose it's semantic value as a heading (i.e. I might not be announced when you ask the screen-reader to read all the headings on the page).
Therefore the heading should contain a button inside it. It already features a span which we could assign role=button to accomplish exactly that.
<h2 class="section-heading collapsible-heading..."> <toggle-arrow/> <span class="mw-headline" aria-expanded="false" aria-controls="content-id">Section heading text</span> <edit-icon/> </h2> <div id="content-id">...</div>
The only notable change would be the focus outline moving from h2 to the span.mw-headline, which seems acceptable.
Toggle arrow remains clickable as well.
As to the announcement of CSS tables, a newer flex-box-based layout might be more appropriate for these headings.
This article https://inclusive-components.design/collapsible-sections/ provides a good overview of how collapsible sections should behave.
- [- ] When tabbing through sections with a screen-reader, the screen-reader should say “expanded” or “collapsed” for each section. This is achieved with the aria-expanded attribute.
- [- ] The section headings should also also announce themselves as buttons.
- [- ] When collapsing or expanding a section with a screen-reader, the reader should announce the new state of the section.
- Section heading should not be announced as tables. – Seems to be a know NVDA bug
- QA should prioritize Android or iOS for this behaviour, since mobile devices have sections collapsed by default.
- Needs to be tested on simplified talk pages as well as they are featuring a slightly different DOM than article pages.