Problem
WCAG 2.5.3 Label in Name requires that the accessible name of a control contains the visible label text. The FieldStorageReuseForm "Re-use" button has an aria-label that spells the word differently and does not start with the visible text.
Visible text: "Re-use"
Accessible name: "Reuse @field_name"
The visible text "Re-use" (with hyphen) is not contained in the aria-label "Reuse" (without hyphen). A speech recognition user who says "Click Re-use" will not match.
Proposed resolution
Change the aria-label to start with the visible text "Re-use":
'aria-label' => $this->t('Re-use @field_name', ['@field_name' => $field['field_name']]),
File
core/modules/field_ui/src/Form/FieldStorageReuseForm.php— line 167
Test
Add a FunctionalJavascript test that:
- Visits the field storage reuse page
- Asserts each "Re-use" button's aria-label starts with the visible text "Re-use"
Related
AI Disclaimer: This was done with a lot of help from AI.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3611423-after.png | 251.37 KB | nisha_j |
| #6 | 3611423-before.png | 288.55 KB | nisha_j |
Issue fork drupal-3611423
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3611423-fieldstoragereuseform-aria-label-reuse
changes, plain diff MR !17333
Comments
Comment #2
mgiffordComment #5
tiago commentedMR !17333 changes the
aria-labelof the "Re-use" button to "Re-use @field_name", as proposed in the summary, so the accessible name starts with the visible label.FieldUiTestTrait::fieldUIAddExistingField()now also checks thearia-label, so every test that re-uses a field covers it. Without the fix it fails with: The text "Re-use field_test" was not found in the attribute "aria-label".Comment #6
nisha_j commentedReviewed and tested MR !17333 on current main (PHP 8.5).
Manual test
On a site installed from main, with a field on Article re-used on Basic page (Manage fields > Re-use an existing field), I inspected the "Re-use" button:
- Before (main): value="Re-use" but aria-label="Reuse field_summary_note". The accessible name doesn't contain the visible label.
- After applying MR !17333: aria-label="Re-use field_summary_note". The accessible name now starts with the visible label, which meets WCAG 2.5.3 Label in Name.
Screenshots of both are attached.
Marking RTBC.
Comment #7
alexpottBackported to 11.5.x as a patch safe bug fix.
Committed and pushed eef285cd039 to main and e8b0a4075e9 to 12.0.x and 39f1fd498d3 to 11.x and 464685c40bf to 11.5.x. Thanks!