Opened 13 months ago
Closed 13 months ago
#62926 closed defect (bug) (wontfix)
Redundant "for" in nav-menus
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | trivial | Version: | |
| Component: | Menus | Keywords: | has-patch close |
| Focuses: | accessibility | Cc: |
Description (last modified by )
/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
#2
@
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
@
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
forattributes 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.
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 aforattribute that is unnecessary because the associated<input>is nested within the<label>. Removing theforattribute simplifies the code without affecting functionality.Trac ticket: #62926