WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 5 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
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 (1)

51299.diff (2.2 KB) - added by audrasjb 3 months ago.
Title attribute not displayed anymore but keep the variable for backward compatibility

Download all attachments as: .zip

Change History (14)

#1 @afercia
3 months ago

  • Keywords title-attribute added

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


3 months ago

#3 @afercia
3 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
3 months ago

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

#4 @audrasjb
3 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
2 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 2 months ago by SergeyBiryukov (previous) (diff)

#6 in reply to: ↑ 5 @afercia
2 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 (or maybe added later) :)

Last edited 2 months ago by afercia (previous) (diff)

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


2 months ago

#8 @hellofromTonya
2 months ago

  • Keywords needs-dev-note added

Per @audrasjb in Slack conversation:

This change will probably deserve a small dev note, too

#9 @sabernhardt
2 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.


7 weeks ago

#11 @audrasjb
7 weeks 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
7 weeks ago

  • Keywords has-patch removed

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

#13 @afercia
5 weeks 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.

Note: See TracTickets for help on using tickets.