Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#31749 closed defect (bug) (fixed)

submit_button() should not output empty name attribute

Reported by: afercia's profile afercia Owned by: azaozz's profile azaozz
Milestone: 4.2 Priority: normal
Severity: normal Version: 4.1
Component: Administration Keywords: has-patch
Focuses: ui, accessibility Cc:


Quickly discussed on Slack with @azaozz and the accessibility team, see

submit_button(), see also get_submit_button(), outputs an empty name attribute when an empty string is passed. This happens in several places in the admin, see for example in class WP_List_Table, where search_box() calls it this way:
submit_button( $text, 'button', '', false, array('id' => 'search-submit') );

According to the specs: Naming form controls: the name attribute
The name content attribute gives the name of the form control, as used in form submission and in the form element's elements object. If the attribute is specified, its value must not be the empty string.

Would recommend to fix this not just for the sake of formal compliance with the specs but also because seems is triggering a weird bug in ChromeVox, TL;DR, reported by our accessibility testers group:

Michelle DeYoung
When tabbing the user can tab to the action links in the Comments section and access them. I did notice that if ‘Quick Edit’ is selected the user is jumped out of the table and focus is taken to the Search box.

Regardless of browsers and Assistive Technologies bugs, an empty name attribute it's pretty useless and seems it doesn't harm to remove it. See proposed patch and some screenshots for reference.

Attachments (1)

31749.patch (731 bytes) - added by afercia 9 years ago.

Download all attachments as: .zip

Change History (7)

9 years ago

#1 @afercia
9 years ago

  • Keywords has-patch added

#2 @SergeyBiryukov
9 years ago

  • Milestone changed from Awaiting Review to 4.2

#3 follow-up: @SergeyBiryukov
9 years ago

Should the same be applied to id attribute?

#4 in reply to: ↑ 3 @azaozz
9 years ago

Replying to SergeyBiryukov:

Sure, there is no point in having empty ID attributes. This function seems somewhat redundant, and at 42 lines of code it is more constraining than useful... Seems it just complicates something as simple as adding one HTML tag.

No wonder it is not used most of the time. As far as I see it is used only at 5 places in wp-admin, and there are about 40 "standard" submit buttons :) Perhaps we should look into deprecating it.

#5 @SergeyBiryukov
9 years ago

Yep, #20492 clearly shows why it's hard to use it.

#6 @azaozz
9 years ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In 31880:

Do not output empty name and id HTML attributes in get_submit_button().
Props afercia. Fixes #31749.

Note: See TracTickets for help on using tickets.