Opened 9 years ago
Closed 8 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 |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.1 |
| Component: | Themes | Version: | |
| Severity: | normal | Keywords: | good-first-bug aria-current has-patch |
| Cc: | Focuses: | accessibility |
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.
9 years ago
#4
@
9 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
@
9 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
@
9 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.
9 years ago
#9
@
9 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.
But aria-current is not outputted if theme uses default wp_page_menu as a fallback in wp_nav_menu. Not sure if this is a problem.
#10
@
9 years ago
But
aria-currentis not outputted if theme uses defaultwp_page_menuas 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
@
9 years ago
- Keywords has-patch added
- Owner set to
- Status new → assigned
Assigning to mark the good-first-bug as "claimed".
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Created patch to add aria-current to aria-current to output of Walker_Nav_Menu for front-end navs