[1.0.0-rc2] Fix aria-current for buttons in nav_menu

Created on 2 May 2024, 7 months ago
Updated 7 June 2024, 6 months ago

Problem/Motivation

When using a menu with levels, all "active trails" elements (button in level 1, and a in level 2) have aria-current="page".
However, it should be only the link (a) that have aria-current="page", and the "parent" button should have aria-current="true".

The difference is subtle between "true" and "page" : "page" is meant for the link of the page currently visited, whereas "true" means the button is somehow "currently active" (because it appears highlighted in the menu) but does not refer to the visited page itself (usually it refers to a parent page or category).
This is an accessibility concern.

The example on DSFR documentation is correct on this point : https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/na...

Some documentation about aria-current : https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attribut...

Steps to reproduce

Configure a menu as the main menu, with a parent level and children links.

Proposed resolution

In pattern-nav-menu.html.twig : for all the buttons, replace aria-current="page" with aria-current="true" (in the "in_active_trail" conditions).

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇫🇷France mh_nichts

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024