Use aria-current=page in pagination links.

Created on 13 March 2018, almost 7 years ago
Updated 31 August 2023, over 1 year ago

Problem/Motivation

WAI-ARIA 1.1 introduces a useful new property: aria-current.

One place where we can use this is on pagination links. Currently, the pager styles in Seven and Bartik have a visual indication of the current page, together with a .visually-hidden span to say it is the current page (which screen readers announce). It's working fine at the moment, but we can modernize this.

The idea behind the aria-current="page" is to indicate this in a machine-readable way that can be conveyed to assistive technology though the platform-level accessibility APIs. The advantage is that screen readers, etc., can present the information in a way that is more consistent with native applications on host platform, such as:

  • Announce it with a platform-localized string (from assistive tech on the host OS), instead of an author-localized string (from Drupal translations).
  • Decide how/when to announce the fact, possibly based on user preferences in the host OS or assistive tech (e.g. screen reader verbosity prefs).

Demo page: http://design-patterns.tink.uk/aria-current/ (includes test results for various devices)

Proposed resolution

  • Add aria-current="page" to the current page link in the pager.
    Important: this should go on the <a> element, not the <li>wrapper.
  • Remove the visually-hidden phrase "current page" from inside the current-page link. Just use<span class="visually-hidden">Page: </span> like all the other numbered links.

From #94 we will try and use theme_preprocess_page() to add this variable.

Remaining tasks

  • Assess: is there sufficient support for aria-current="page" across various browsers, assistive tech, and OS? Ask around the wider accessibility community. In particular, we'd like to know where it isn't supported yet, to assess the regression risk.
    • DONE: support looks good in general (comment #3). iOS + macOS Safari work, and there are several browser/screen-reader combinations working on Windows.
    • DONE: ChromeVox + desktop Chrome Browser. Not currently working, see comment #7.
    • TODO: monitor Android Talkback, not working yet (comment #6).
    • TODO: monitor support with MS Edge + JAWS. Watch this bug report: No support for aria-current in Edge.
    • DONE: Monitor support for MS Edge + Narrator. WAI-ARIA 1.1 is support is "in development" according to MS Edge Platform Status. See comment #57
    • DONE: Test in ChromeVox on ChromeOS. See comment #7 and #50
    • DONE: test macOS Voiceover with Chrome. See comment #50
  • Assess: does this impact on a template in the Stable and Classy themes?
  • Write a patch.
  • Update using hook vs twig templates
  • Tests

Sign-offs needed

IMPORTANT: Possible regression risk - get sign-off from an accessibility maintainer, @andrewmacpherson or @mgifford.
Don't commit this until we're confident there's enough support across various OS, browsers, and assistive tech. It can wait until the time is right, and go in any minor release.

User interface changes

  • Improved semantics for assisitive technology. Replace an invisible text span with machine readable attribute.
  • No changes to visual design, or CSS.

API changes

None.

Data model changes

None.

Commit Credits needed

@RachelOlivero - researched Android Talkback support, comments #6 and #38.

Feature request
Status

Fixed

Version

10.1

Component
Markup 

Last updated about 1 month ago

No maintainer
Created by

🇬🇧United Kingdom andrewmacpherson

Live updates comments and jobs are added and updated live.
  • Accessibility

    It affects the ability of people with disabilities or special needs (such as blindness or color-blindness) to use Drupal.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024