-
savedaws
I am receiving the following accessibility errors for the astra primary menu:
Menu dropdowns should be tagged for assistive technology.
Menu items that have a dropdown should include an aria-haspopup=”true” attribute.
Code snapshots of failed elements
<a href="https://timberlinemtguides.com/trip_location/ski-mountaineering/" >Ski Mountaineering<span role="presentation" class="dropdown-menu-toggle" ></span></a>
Dropdown expanded/collapsed state should be represented in the code.
Menu items that have a dropdown should include an “aria-expanded” attribute set to “false” by default, which changes to “true” when the dropdown is opened, and back to “false” when closed.
Code snapshots of failed elements
<a href="https://timberlinemtguides.com/trip_location/ski-mountaineering/" >Ski Mountaineering<span role="presentation" class="dropdown-menu-toggle" ></span></a>
Are there ways that I can address this? Or is this something that GeneratePress has to update?
I’m using the WordPress menu in GP’s header. -
Alvind
Hi there,
Adding this snippet should resolve the accessibility error in your case:
function add_aria_expanded_attribute( $atts, $item, $args, $depth ) { // Check if the current menu item has children if ( in_array( 'menu-item-has-children', $item->classes ) ) { // Add the aria-expanded=false attr $atts['aria-expanded'] = 'false'; $atts['aria-haspopup'] = 'true'; } return $atts; } add_filter( 'nav_menu_link_attributes', 'add_aria_expanded_attribute', 10, 4 );
Adding PHP: https://docs.generatepress.com/article/adding-php/
-
savedaws
Thanks that worked.
Is this something that will be included in future releases?
Moving forward, do I need to look to update this inserted code to accommodate possible future changes to accessibility standards?
-
Alvind
Accessibility improvement is something we are actively working on in the theme, and we are exploring the best ways to accommodate these changes.
For now, you can use the snippet, and any future changes will definitely be communicated to our users.
- You must be logged in to reply to this topic.