Opened 3 years ago
Last modified 22 months ago
#51299 assigned defect (bug)
Remove the title attribute from Walker_Nav_Menu
Reported by: |
|
Owned by: |
|
---|---|---|---|
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)
Change History (19)
This ticket was mentioned in Slack in #accessibility by afercia. View the logs.
3 years ago
#3
@
3 years ago
- Milestone changed from Awaiting Review to 5.6
- Owner set to Hareesh Pillai
- Status changed from new to assigned
@
3 years ago
Title attribute not displayed anymore but keep the variable for backward compatibility
#4
@
3 years 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:
↓ 6
@
3 years ago
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 thenav_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?
#6
in reply to:
↑ 5
@
3 years 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) :)
This ticket was mentioned in Slack in #accessibility by afercia. View the logs.
3 years ago
#8
@
3 years ago
- Keywords needs-dev-note added
Per @audrasjb in Slack conversation:
This change will probably deserve a small dev note, too
#9
@
3 years 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,
- no title attributes output and
- 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
- when provided and
- 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.
3 years ago
#11
@
3 years 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
@
3 years ago
- Keywords has-patch removed
Removing has-patch
as the implementation may change once an implementation direction is decided upon.
#13
@
3 years 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.
#14
@
23 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.
This ticket was discussed during today's accessibility bug-scrub: agreed to move it to the 5.6 milestone.