Make WordPress Core

Opened 13 years ago

Closed 10 years ago

Last modified 7 years ago

#18650 closed enhancement (fixed)

Make archives and categories widgets dropdown ada compliant

Reported by: jlevandowski's profile jlevandowski Owned by: joedolson's profile joedolson
Milestone: 4.2 Priority: normal
Severity: major Version: 3.2.1
Component: Widgets Keywords: has-patch commit
Focuses: accessibility Cc:

Description

Conditionally add the <label> tag for the archives and categories widgets so they are ada compliant.

http://webaim.org/techniques/forms/controls

Attachments (11)

widgets-patch.diff (1.8 KB) - added by jlevandowski 13 years ago.
18650-patch.diff (2.5 KB) - added by jlevandowski 13 years ago.
18650.2.patch (3.0 KB) - added by SergeyBiryukov 12 years ago.
18650.patch (4.1 KB) - added by DrewAPicture 11 years ago.
esc_attr_e
18650.diff (4.1 KB) - added by nacin 11 years ago.
18650.6.patch (2.4 KB) - added by joedolson 10 years ago.
Refresh of patch.
18650.3.patch (2.3 KB) - added by DrewAPicture 10 years ago.
18650.6.png (3.3 KB) - added by SergeyBiryukov 10 years ago.
18650.7.patch (3.0 KB) - added by SergeyBiryukov 10 years ago.
18650.8.patch (2.9 KB) - added by SergeyBiryukov 10 years ago.
18650.9.patch (2.1 KB) - added by SergeyBiryukov 10 years ago.

Download all attachments as: .zip

Change History (43)

#2 @GaryJ
13 years ago

I'd prefer to see the <select> element get an id attribute that had the widget ID as a suffix - that way, more than one archive dropdown widget can be used on a page with valid unique ids.

#3 @jlevandowski
13 years ago

Added patch that adds widget id so that more than one widget of the same kind can be used on a page.

#4 @jlevandowski
12 years ago

  • Component changed from Widgets to Accessibility
  • Keywords dev-feedback added

#5 @webstoc
12 years ago

  • Severity changed from normal to major

We verified that the patch fixes red flags in the WAVE toolbar. Curious what the hold up is on reviewing the patch by jlevandowski and getting it into the widgets? There are dozens (if not hundreds) of .gov sites using WordPress that need these fixes. As an "accessibility" issue, this more than of a "major" than "normal" severity.

Last edited 12 years ago by webstoc (previous) (diff)

#6 @webstoc
12 years ago

  • Cc webstoc added

#7 follow-up: @SergeyBiryukov
12 years ago

  • Milestone changed from Awaiting Review to 3.6

Refreshed the patch.

Not sure if changing the existing id attribute for Categories widget is a good idea though. I guess it may lead to unexpected results in some themes.

#8 @SergeyBiryukov
12 years ago

#16527 was marked as a duplicate.

@DrewAPicture
11 years ago

esc_attr_e

#9 in reply to: ↑ 7 @DrewAPicture
11 years ago

Replying to SergeyBiryukov:

Not sure if changing the existing id attribute for Categories widget is a good idea though. I guess it may lead to unexpected results in some themes.

I see where you're coming from on this. And I can see why the inner select id was left alone -- the main widget id is unique for each instance just as with the other core widgets. On that same token, themes shouldn't have been targeting ids since they are by nature meant to be unique anyway.

18650.patch builds off 18650.2.patch and swaps out echo esc_attr( __( 'String' ) ) for esc_attr_e( 'String' )

#10 @ocean90
11 years ago

  • Milestone changed from 3.6 to Future Release

#11 @grahamarmfield
11 years ago

  • Cc graham.armfield@… added

#12 @nacin
11 years ago

  • Component changed from Accessibility to Widgets
  • Focuses accessibility added

#13 @joedolson
11 years ago

Is there something in particular that this ticket is waiting on?

#14 @nacin
11 years ago

  • Keywords dev-feedback removed
  • Milestone changed from Future Release to 3.9

Changing the IDs for these are precarious as themes may be using them for styling (the first instance, anyway). I could go for trying this out, though I wouldn't mind seeing if we could tweak it.

There is a lot of repetitive string building in this patch. A property or method specific to that widget would likely help clean that up.

#15 @GaryJ
11 years ago

Worth adding a class to the select elements, so that themes can start targeting that instead?

@nacin
11 years ago

#16 @nacin
11 years ago

  • Milestone changed from 3.9 to Future Release

So basically:

  • The first instance of the category widget widget should use the current IDs.
  • Subsequent instances should use incremented IDs.

The archives widget doesn't currently have an ID on the select so it doesn't require this juggling.

I've attached 18650.diff to do this. The problem is, I think the labels wrapping the title have the potential to break a theme's styling of the header. (Imagine <h3><label>Title</label></h3> with label styling overriding h3 styling. An alternative would probably be screen reader text, which we actually don't necessarily have the classes for on the frontend.

As it is, these are not accessible due to the lack of a submit button, while at the very least the first options are "Select Month" and "Select Category", which provide a clue it's a JS jump menu. I'm not inclined to touch this without further consideration.

#17 @GaryJ
10 years ago

Putting this out there, because.

Since the current widgets have some problems:

  • No submit button
  • No non-title label
  • Missing or non-unique IDs
  • Obtrusive JS (onchange)
  • Whatever else other open tickets might say is wrong

...that make front-end changes, is there potential for creating new widgets (different $id_base) that address all of these problems, only making these available to new installs, and hiding the old versions from new installs?

#18 @joedolson
10 years ago

I'm open to this; this would open the path for eventual deprecation of the old widget.

#19 @ctalkington
10 years ago

new widgets that are a bit smarter in regards to accessibility and modern approaches while letting the old widgets remain in a soft-deprecate stage for back-compat is an intriguing thought. i think this approach has been used for different things before, just not widgets?

it seems like doing theme support could potentially work here but would add a bit of overhead based on the level of adjustment that is needed.

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


10 years ago

#21 @joedolson
10 years ago

  • Milestone changed from Future Release to 4.2
  • Owner set to joedolson
  • Priority changed from normal to high
  • Status changed from new to assigned

#22 follow-up: @joedolson
10 years ago

Attached patch is a refresh of Nacin's patch, but uses .screen-reader-text and inserts labels separately from the title content.

Also defines the static variable $first only if the widget is a dropdown, so that non-dropdown versions of the widget don't alter the value.

This doesn't handle the question of adding a submit button. If we add a submit button, we need to also remove the onchange handling.

@joedolson
10 years ago

Refresh of patch.

#23 @SergeyBiryukov
10 years ago

In 18650.6.patch, echo esc_attr( $label ) should not be replaced with esc_attr_e( $label ).

$label is a variable, not a translatable string, so echo esc_attr() is correct there.

#24 @DrewAPicture
10 years ago

  • Status changed from assigned to reviewing

18650.3.patch addresses feedback from @SergeyBiryukov in comment:23 and also escapes a couple of output attributes.

@joedolson: Is anything else here outstanding?

Last edited 10 years ago by DrewAPicture (previous) (diff)

#25 @joedolson
10 years ago

That does it as far as I can see.

#26 @DrewAPicture
10 years ago

  • Keywords commit added

#27 in reply to: ↑ 22 @SergeyBiryukov
10 years ago

Replying to joedolson:

Attached patch is a refresh of Nacin's patch, but uses .screen-reader-text and inserts labels separately from the title content.

That would result in duplicate widget title and label if the theme doesn't support .screen-reader-text, see 18650.6.png.

The alternative is to turn widget titles into labels, but that might result in label styling overriding the header styling, as noted in comment:16.

I've attached two patches which rename some variables for clarity, and only add labels if $title is not empty, to avoid printing an empty label if the title was filtered out by the theme.

Which approach are we more comfortable with?

Last edited 10 years ago by SergeyBiryukov (previous) (diff)

#28 follow-up: @joedolson
10 years ago

It was actually entirely intentional that the screen reader text should be added. The text should be present as both a widget title and as a field label. The presence of the widget title doesn't matter significantly for accessibility, but the field label does.

Only adding labels if $title is not empty means that the form field has no label, which is not an acceptable solution.

#29 in reply to: ↑ 28 @SergeyBiryukov
10 years ago

Replying to joedolson:

It was actually entirely intentional that the screen reader text should be added. The text should be present as both a widget title and as a field label.

Thanks for the clarification, 18650.9.patch should be good to go then.

#30 @SergeyBiryukov
10 years ago

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

In 31520:

Add missing labels to Archives and Categories dropdown widgets.

props joedolson, jlevandowski, DrewAPicture, SergeyBiryukov.
fixes #18650.

#31 @DrewAPicture
10 years ago

  • Priority changed from high to normal

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


7 years ago

Note: See TracTickets for help on using tickets.