WordPress.org

Make WordPress Core

Opened 13 months ago

Last modified 7 weeks ago

#51299 assigned defect (bug)

Remove the title attribute from Walker_Nav_Menu

Reported by: Hareesh Pillai Owned by: Hareesh Pillai
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Menus Keywords: title-attribute has-patch
Focuses: accessibility Cc:

Description

As highlighted in one of the comments for the Accessibility Team’s goals for WordPress 5.6 and beyond post, the title attribute has to be removed from nav walker menus. This creates repetitive screen reader announcements for some screen reader/browser combinations.

Attachments (3)

51299.diff (2.2 KB) - added by audrasjb 12 months ago.
Title attribute not displayed anymore but keep the variable for backward compatibility
51299.1.diff (2.3 KB) - added by sabernhardt 2 months ago.
removing redundant tooltips
51299.2.diff (1.3 KB) - added by sabernhardt 7 weeks ago.

Download all attachments as: .zip

Change History (19)

#1 @afercia
12 months ago

  • Keywords title-attribute added

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


12 months ago

#3 @afercia
12 months ago

  • Milestone changed from Awaiting Review to 5.6
  • Owner set to Hareesh Pillai
  • Status changed from new to assigned

This ticket was discussed during today's accessibility bug-scrub: agreed to move it to the 5.6 milestone.

@audrasjb
12 months ago

Title attribute not displayed anymore but keep the variable for backward compatibility

#4 @audrasjb
12 months ago

  • Keywords has-patch added; needs-patch removed

In 51299.diff, we're not displaying title attribute anymore, but we keep the (emptied) variable for backward compatibility.

Any thoughts on this approach, @afercia or @SergeyBiryukov?

#5 follow-up: @SergeyBiryukov
12 months ago

Related: #24766, #32218.

Thanks for the patch! Some thoughts:

  • From a technical point of view, if the $title variable is not used anywhere else in the class and is not passed to any filters, I don't think it makes sense to keep it. I see it being passed to the nav_menu_item_title filter, but the result of that is no longer used anywhere after this patch.
  • I think this will have big front-end implications for a lot of websites. For example, https://wordpress.org/ has these title attributes on some menu items. With this change, would they be gone?
    • Documentation: "Documentation, tutorials, best practices."
    • Forums: "Support and discussion forums."
    • Five for the Future: "How five percent is powering the next generation of the web"
  • Would this make the "Title Attribute" input on the Menus screen completely unused?
  • How would developers be able to restore previous behavior?
Last edited 12 months ago by SergeyBiryukov (previous) (diff)

#6 in reply to: ↑ 5 @afercia
12 months ago

I'd agree there are backwards compatibility concerns here.

So far, in the last years the accessibility team made an effort to remove as many title attributes as possible from files in the wp-admin directory. As mentioned on the tracking ticket #24766, that brought down the occurrences of title attributes in the wp-admin codebase from 157 in 37 files to 16 occurrences. We can't just remove them.

It would be nice if WordPress would have a well established deprecation policy for this kind of things. Given the lack of it, I'd tend to think there's the need to explore a way to make these changes in a non-breaking way.

I'm not sure a new theme-support item would be the best option, as it would restrict important accessibility improvements only to the themes that declare support for that option. Also, I've seen plugins (incorrectly) using title attributes for all sort of things, for example image gallery plugins. It would be great to explore new ideas to make the removal of title attributes not break anything. Any suggestions welcome :)

However, when it comes to title attributes in the wp-includes directory, things are pretty different. Most of these title attributes are used in functions meant to be used in the front end.

Replying to SergeyBiryukov:

  • I think this will have big front-end implications for a lot of websites. For example, https://wordpress.org/ has these title attributes on some menu items. With this change, would they be gone?
    • Documentation: "Documentation, tutorials, best practices."
    • Forums: "Support and discussion forums."
    • Five for the Future: "How five percent is powering the next generation of the web"

For the specific case of wp.org, in https://meta.trac.wordpress.org/ticket/4091 the accessibility team asked to remove the title attributes from the menu and that was done for the top level items. It appears the sub-items were missed :)

Version 0, edited 12 months ago by afercia (next)

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


12 months ago

#8 @hellofromTonya
12 months ago

  • Keywords needs-dev-note added

Per @audrasjb in Slack conversation:

This change will probably deserve a small dev note, too

#9 @sabernhardt
12 months ago

For backward compatibility, I think a filter would fit better than using theme-support. If there is a reason to keep title attributes, that should carry over when switching themes.

Suggested behavior:

If the filter would return false,

  1. no title attributes output and
  2. the menus admin page does not show the input field for editing titles.

If the filter is true (and/or customized), the nav menu would include the attributes

  1. when provided and
  2. when they do not match the link text (automatically removing when redundant).

Adding the filter would only make sense if false is default, though. (If you know you don't want the attributes included, you can empty the input for each list item already.)

Another possibility is following @williampatton's idea for deprecation in themes, so the change is established as opt-in for one release and then the default is switched in the next.

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


11 months ago

#11 @audrasjb
11 months ago

  • Milestone changed from 5.6 to Future Release

Moving to Future release as this ticket still needs some discussion.
@sabernhardt ’s approach looks good to me by the way.

#12 @hellofromTonya
11 months ago

  • Keywords has-patch removed

Removing has-patch as the implementation may change once an implementation direction is decided upon.

#13 @afercia
11 months ago

  • Keywords needs-dev-note removed

Removing needs-dev-note as this ticket isn't milestoned for a specific release yet nor any change has been committed yet.

@sabernhardt
2 months ago

removing redundant tooltips

#14 @sabernhardt
2 months ago

  • Keywords needs-patch added

I'm not sure now whether adding a filter is worth much. With or without that, we can avoid showing/speaking exactly the same information as the link text in the title attribute.

So 51299.1.diff takes care of removing redundant tooltips. The $title variable needed to be moved earlier.

#15 @sabernhardt
2 months ago

  • Keywords has-patch added; needs-patch removed

@sabernhardt
7 weeks ago

#16 @sabernhardt
7 weeks ago

In 51299.2.diff, only the_title filter is moved before $atts array. Also, the condition for removing superfluous title attributes is grouped with the existing conditional statement to avoid comparing against an empty string.

Note: See TracTickets for help on using tickets.