Add aria-current attribute to navigation items

Created on 8 March 2019, over 5 years ago
Updated 16 April 2024, 2 months ago

Problem/Motivation

In a set of links such as a menu, the currently-active link has the is-active class added so it can be styled to make it visually apparent that this link goes to the current page. This information should also be made available programmatically. In order to do this, the aria-current attribute can be set to "page."

The attribute should be added to the link, not a list item or other element. If the currently-active item is not linked to (for example, if the link is removed when the target is the current page, such as in breadcrumbs where the page title is displayed), then the aria-current attribute is not required.

References:

Steps to reproduce

  1. Install the latest version of Drupal using the standard profile.
  2. Create three basic pages and add them to the main menu. Note they appear as links in the main menu region.
  3. Follow one of the links in the main menu.
  4. Inspect the code of the link to the current page. Note that it is still a link and it has the is-active class. Note that it does not have an aria-current attribute.

Proposed resolution

Add aria-current="page" to all links where the is-active class is being added. Do not add the attribute to non-links; do not add it when the current item is not a page (for example, tab panels, steps in a form, etc).

Remaining tasks

Manual testing of other places where the is-active class is added. Test pagination links in Views etc.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

TBD.

📌 Task
Status

Fixed

Version

11.0 🔥

Component
Markup 

Last updated 6 days ago

No maintainer
Created by

🇷🇺Russia Chi

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

Merge Requests

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.69.0 2024