Make WordPress Core

Opened 4 years ago

Closed 3 years ago

#51628 closed enhancement (wontfix)

add arg "aria-label" to wp_dropdown_categories

Reported by: greghy's profile greghy Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.5
Component: Themes Keywords: reporter-feedback
Focuses: accessibility Cc:


Doing an accessibility check on a site I found that [wp_dropdown_categories]( generates a <select>, without any label.

I think a good solution could be to add to the function args the possibility to set the aria-label attribute.

Change History (6)

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

4 years ago

#2 @joedolson
4 years ago

  • Keywords reporter-feedback added

What is the usage you're finding for this function that outputs a form without a label? The function itself should not produce a label, as that would create conflicts with the existing usages of the function - it's only designed to produce the select list, and the associated label comes from the calling context. Adding an aria-label would create instances where there was a mismatch between the visual label and the label perceived by screen readers, which would definitely be a problem.

It's plausible that we could add the ability to set an aria-label attribute on demand, but since aria-label is only perceivable by screen readers, we don't particularly want to encourage that usage.

However, the context where you're seeing this select without a label might be one where core needs to ensure that there's a label; can you tell us where you're seeing this problem?

#3 @greghy
4 years ago

In a theme that I am fixing accessibility side has been inserted the select, without label. For this I would like to add the aria-label attribute. I think it could be useful to have an argument of the function to set ad-hoc attributes (like aria-label or aria-labelledby or others).

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

4 years ago

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

3 years ago

#6 @joedolson
3 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Hi, @greghy! After discussion, this isn't something we're going to pursue. There are a couple of reasons; mostly, there's a problem that an aria-label attribute would always override any visible label, so this could easily create a new issue with mismatched labeling, if somebody was trying to add a visible label to a field that had been passed an aria-label.

Having a label on the field in a theme is easily resolved by using a .screen-reader-text class to hide the label (or, of course, by leaving it visible.)

The purpose of the function is just to generate the select list; any labeling should be left to the usage.

If necessary, you could use the existing wp_dropdown_cats filter to modify the output HTML.

Note: See TracTickets for help on using tickets.