Make WordPress Core

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's profile williampatton Owned by: chetan200891's profile 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 SergeyBiryukov)

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)

43191.diff (602 bytes) - added by chetan200891 7 years ago.
Created patch to add aria-current to aria-current to output of Walker_Nav_Menu for front-end navs
43191.2.diff (1.9 KB) - added by chetan200891 7 years ago.
Updated patch.
43191.3.diff (1.8 KB) - added by sami.keijonen 7 years ago.

Download all attachments as: .zip

Change History (20)

This ticket was mentioned in Slack in #accessibility by williampatton. View the logs.


7 years ago

#2 @SergeyBiryukov
7 years ago

  • Description modified (diff)
  • Keywords good-first-bug added

#3 @afercia
7 years ago

  • Keywords aria-current added

@chetan200891
7 years ago

Created patch to add aria-current to aria-current to output of Walker_Nav_Menu for front-end navs

#4 @chetan200891
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.

#5 @SergeyBiryukov
7 years ago

  • Milestone changed from Awaiting Review to 5.0

#6 @afercia
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.

@chetan200891
7 years ago

Updated patch.

#7 @chetan200891
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 @sami.keijonen
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

Version 0, edited 7 years ago by sami.keijonen (next)

#10 @afercia
7 years ago

But aria-current is not outputted if theme uses default wp_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 @DrewAPicture
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".

#12 @afercia
7 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 42808:

Accessibility: Themes: use aria-current for the Walker_Nav_Menu current link.

The aria-current attribute is a simple, effective way to help assistive
technologies users orientate themselves within a list of items. Continues the
introduction in core of aria-current after [42440], [41683], [41359], and [41371].

Props williampatton, chetan200891, sami.keijonen.
Fixes #43191.

#13 @audrasjb
6 years ago

  • Keywords fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for 4.9.9 consideration as seen during accessibility team bug-scrub meeting.

#14 @SergeyBiryukov
6 years ago

  • Milestone changed from 5.0 to 4.9.9

#15 @pento
6 years ago

  • Milestone changed from 4.9.9 to 5.0.1

#16 @pento
6 years ago

  • Milestone changed from 5.0.1 to 5.0.2

#17 @pento
6 years ago

  • Keywords fixed-major removed
  • Milestone changed from 5.0.2 to 5.1
  • Resolution set to fixed
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.