Problem

WCAG 2.5.3 Label in Name requires that the accessible name of a control contains the visible label text. In CommentAdminOverview, "Edit" links are repeated for every comment in the moderation queue with no aria-label or visually-hidden text to distinguish them.

Visible text: "Edit" (repeated per comment)

Accessible name: "Edit" (identical for every row)

A speech recognition user who says "Click Edit" will see all matching links highlighted with numbers. They must then say the correct number to select the one they want — for every single action.


Proposed resolution

Add an aria-label that includes the comment subject or author for disambiguation:

$links['edit'] = [
  'title' => $this->t('Edit'),
  'url' => $comment->toUrl('edit-form', $comment_uri_options),
  'attributes' => [
    'aria-label' => $this->t('Edit comment by @author on @subject', [
      '@author' => $comment->getAuthorName(),
      '@subject' => $comment->getSubject(),
    ]),
  ],
];

File

  • core/modules/comment/src/Form/CommentAdminOverview.php — lines 227-230

Test

Add a FunctionalJavascript test that:

  1. Creates multiple comments on a node
  2. Visits the comment admin page
  3. Asserts each Edit link has a unique aria-label containing the comment subject or author

Related

AI Disclaimer: This was done with a lot of help from AI.

Comments

mgifford created an issue. See original summary.

mgifford’s picture

Component: edit.module » comment.module
mgifford’s picture

Issue summary: View changes