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:

  1. Visits the field storage reuse page
  2. 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.

CommentFileSizeAuthor
#6 3611423-after.png251.37 KBnisha_j
#6 3611423-before.png288.55 KBnisha_j

Issue fork drupal-3611423

Command icon 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:

Comments

mgifford created an issue. See original summary.

mgifford’s picture

Issue summary: View changes

tiago made their first commit to this issue’s fork.

tiago’s picture

Status: Active » Needs review

MR !17333 changes the aria-label of 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 the aria-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".

nisha_j’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new288.55 KB
new251.37 KB

Reviewed 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.

alexpott’s picture

Version: main » 11.5.x-dev
Status: Reviewed & tested by the community » Fixed

Backported 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!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed 464685c4 on 11.5.x
    fix: #3611423 FieldStorageReuseForm aria-label "Reuse" vs visible "Re-...

  • alexpott committed 39f1fd49 on 11.x
    fix: #3611423 FieldStorageReuseForm aria-label "Reuse" vs visible "Re-...

  • alexpott committed e8b0a407 on 12.0.x
    fix: #3611423 FieldStorageReuseForm aria-label "Reuse" vs visible "Re-...

  • alexpott committed eef285cd on main
    fix: #3611423 FieldStorageReuseForm aria-label "Reuse" vs visible "Re-...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.