Opened 7 years ago
Closed 6 years ago
#43191 closed enhancement (fixed)
Add aria-current to output of Walker_Nav_Menu for front-end navs
Reported by: | williampatton | Owned by: | chetan200891 |
---|---|---|---|
Milestone: | 5.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Themes | Keywords: | good-first-bug aria-current has-patch |
Focuses: | accessibility | Cc: |
Description (last modified by )
With recent passes on navigations to add aria-current
the idea was brought up about placing it on frontend menus too.
See #40833 and other related tickets here https://core.trac.wordpress.org/query?keywords=~aria-current
Modifications would be required inside the Walker_Nav_Menu class. I will look closer at the required modifications but something as simple as this could be all that is needed:
if ( in_array( 'current-menu-item', $classes, true ) ) { $atts['aria-current'] = 'page'; }
Attachments (3)
Change History (20)
This ticket was mentioned in Slack in #accessibility by williampatton. View the logs.
7 years ago
#4
@
7 years ago
- Keywords needs-patch removed
I have attached patch 43191.diff to add aria-current to aria-current to output of Walker_Nav_Menu for front-end navs.
#6
@
7 years ago
@chetan200891 thanks! I think the nav items have a $item->current
property, maybe it would be better to use that? The new attribute should be documented in the nav_menu_link_attributes
filter docblock.
#7
@
7 years ago
@afercia Thanks for your suggestion. I have updated patch 43191.2.diff based on your suggestion.
This ticket was mentioned in Slack in #accessibility by sami.keijonen. View the logs.
7 years ago
#9
@
7 years ago
Thanks @chetan200891 ! Somehow I could not test your patch, I got two different files question. Could be that it's just me and SVN.
Just in case I uploaded patch 43191.3.diff.
I tested using default themes and couple of random themes from .org. And all seems to work, also in widget menu.
Aria current is not outputted if theme uses default wp_page_menu
as a fallback in wp_nav_menu
#10
@
7 years ago
But
aria-current
is not outputted if theme uses defaultwp_page_menu
as a fallback
I believe wp_page_menu()
uses a different default walker, which is Walker_Page
see walk_page_tree()
. I guess that should go in a separate ticket.
#11
@
7 years ago
- Keywords has-patch added
- Owner set to chetan200891
- Status changed from new to assigned
Assigning to mark the good-first-bug
as "claimed".
Created patch to add aria-current to aria-current to output of Walker_Nav_Menu for front-end navs