Make WordPress Core

#62926 closed defect (bug) (wontfix)

Redundant "for" in nav-menus

Reported by: kkmuffme's profile kkmuffme Owned by:
Milestone: Priority: normal
Severity: trivial Version:
Component: Menus Keywords: has-patch close
Focuses: accessibility Cc:

Description (last modified by sabernhardt)

/wp-admin/nav-menus.php

<label class="bulk-select-button" for="bulk-select-switcher-top">
	<input type="checkbox" id="bulk-select-switcher-top" name="bulk-select-switcher-top" class="bulk-select-switcher">
	<span class="bulk-select-button-label">Bulk Select</span>
</label>

The for= is redundant since the input is nested in the label and can be removed

Change History (4)

This ticket was mentioned in PR #8277 on WordPress/wordpress-develop by @sainathpoojary.


13 months ago
#1

  • Keywords has-patch added

This PR addresses a minor code improvement in the WordPress admin navigation menus. In /wp-admin/nav-menus.php, the <label> element for the bulk select checkbox contains a for attribute that is unnecessary because the associated <input> is nested within the <label>. Removing the for attribute simplifies the code without affecting functionality.

Trac ticket: #62926

#2 @audrasjb
13 months ago

  • Focuses accessibility added
  • Keywords 2nd-opinion added

Hello, thank you for the ticket and PR,
It's difficult to find detailed benchmark on this implementation, but I found at least one resource which shows that using a for attribute on implicit label is better supported by user agents: https://dev.to/thejaredwilcurt/the-truth-behind-implicitexplicit-form-labels-2e10

I don't know if this resource is still relevant but without knowing the implementation in current screen readers, I wouldn't recommend to remove the for attribute.

Adding accessibility focus for a double check from the accessibility team.

#3 @sabernhardt
13 months ago

  • Description modified (diff)
  • Keywords close added

@joedolson already commented about not removing the attributes on a similar ticket:

in no circumstances should we elect to remove the for attributes so that we only use implicit labeling.

[34991] removed the for attributes from hide-column-tog checkboxes, but it kept them for editor-expand-toggle and wp_welcome_panel-hide checkboxes. Removing the attribute seems to have been unintentional.

Possibly switching to explicit association:

  • #21603 created the menu item bulk select labels with implicit label association (only a few years ago).
  • The entire label area (with a border) is clickable in its current design, and the CSS has selectors for this markup.
     label.bulk-select-button:hover,
     label.bulk-select-button:active,
     label.bulk-select-button:focus-within {
    
  • Few directory plugins target .bulk-select-button, but I think any custom styles that might conflict could use more generic selectors.

#4 @audrasjb
13 months ago

  • Keywords 2nd-opinion removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Alright thanks for the second confirmation. I'm therefore closing this ticket as wontfix.

Note: See TracTickets for help on using tickets.