From 53f2a9e87f22739bbdc30c634b2077f87525308c Mon Sep 17 00:00:00 2001 From: Christian Medders - Bixal <88721460+clmedders@users.noreply.github.com> Date: Fri, 5 Jul 2024 18:50:47 -0400 Subject: [PATCH] VOTE-2228: Adding aria-current to main menu items (#812) --- .../menu--main--votegov-mainnavigation.html.twig | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/web/themes/custom/votegov/templates/navigation/menu--main--votegov-mainnavigation.html.twig b/web/themes/custom/votegov/templates/navigation/menu--main--votegov-mainnavigation.html.twig index ae9c59b23..f1386be52 100644 --- a/web/themes/custom/votegov/templates/navigation/menu--main--votegov-mainnavigation.html.twig +++ b/web/themes/custom/votegov/templates/navigation/menu--main--votegov-mainnavigation.html.twig @@ -70,7 +70,10 @@ We call a macro which calls itself to render the full tree. 'usa-nav__link--parent', item.in_active_trail ? 'usa-current' ] %} -
  • {{ link(item.title, item.url, {'class': link_classes}) }}
  • +
  • + {% set link_attributes = item.in_active_trail ? {'aria-current': 'page'} : {} %} + {{ link(item.title, item.url, {'class': link_classes} | merge(link_attributes)) }} +
  • {{ menus.menu_links(item.below, attributes, menu_level + 1, aria_id) }} {% else %} @@ -86,7 +89,8 @@ We call a macro which calls itself to render the full tree. 'usa-nav__link', item.in_active_trail ? 'usa-current' ] %} - {{ link(item.title, item.url, {'class': link_classes}) }} + {% set link_attributes = item.in_active_trail ? {'aria-current': 'page'} : {} %} + {{ link(item.title, item.url, {'class': link_classes} | merge(link_attributes)) }} {% endif %} {% endif %} @@ -97,7 +101,8 @@ We call a macro which calls itself to render the full tree. {% for item in items %}
  • {% if item.url.routeName != '' %} - {{ link(item.title, item.url) }} + {% set link_attributes = item.in_active_trail ? {'aria-current': 'page'} : {} %} + {{ link(item.title, item.url, link_attributes) }} {% else %} {{ item.title }} {% endif %}