Page MenuHomePhabricator

Make generated table of contents a navigation region
Closed, ResolvedPublic

Description

Current:

<div id="toc" class="toc">
  <div id="toctitle">
    <h2>Contents</h2>
    <span class="toctoggle">...</span>
  </div>
  <ul>...</ul>
</div>

A heading and list is pretty good, but I usually see this inside a semantic <nav> or <div role="navigation"> these days, so it can be jumped to as a landmark/region as well. For example, the ToC of the WAI-ARIA recommendation itself. This will be even more useful after T114072 makes sections into regions. Something like this might do the trick:

<div role="navigation" aria-labelledby="tocheading" id="toc" class="toc">
  <div id="toctitle">
    <h2 id="tocheading">Contents</h2>
    <span class="toctoggle">...</span>
  </div>
  <ul>...</ul>
</div>

Event Timeline

Change 268363 had a related patch set uploaded (by Matt Fitzpatrick):
Add ARIA "navigation" role and label to table of contents div

https://gerrit.wikimedia.org/r/268363

Heydon Pickering specifically suggests it to us in his book Inclusive Design Patterns:

image.png (485×528 px, 56 KB)

Absolutely, @TheDJ – I've had no clue there's even a patch already sitting there long – clearly slipped under my radar. Was actively informed by the task of @PerfektesChaos, but haven't had time before my month off in January to closely care about it – thanks for that as well.

Pinging the Parsing team.

@Jdforrester-WMF are you asking in the context of Parsoid? Or more broadly? If the former, Parsoid doesn't yet generate TOC. If the latter, let me know.

Change 268363 merged by jenkins-bot:
[mediawiki/core@master] Add ARIA navigation role and label to table of contents div

https://gerrit.wikimedia.org/r/268363

Thank you @MattFitzpatrick and @PerfektesChaos
Apologies that it took so long

Pinging the Parsing team.

@Jdforrester-WMF are you asking in the context of Parsoid? Or more broadly? If the former, Parsoid doesn't yet generate TOC. If the latter, let me know.

I was asking if the change was architecturally compatible with Parsoid, or if it's OK to merge… but it was merged before I could clarify. ;-)

+1 to what @TheDJ said, thanks @MattFitzpatrick & @PerfektesChaos. Basically majority was in place since 1.28 by @MattFitzpatrick.
Let's settle on better late than never!