Tableselect: "select all rows in this table" header checkbox causing accessibility problems

Created on 11 July 2010, about 14 years ago
Updated 17 April 2024, 5 months ago

Problem Description

When creating a table_select element using the form api, the added column with the checkboxes does not have a valid control labels. A title is added to the input for the "select all" by JS, but is not added to the inputs for each individual row. This causes screen readers such as NVDA to repeat the same "select all rows" title for each row, causing confusion. Ideally the input for each of these rows would be titled with something like 'select row #'.

For instance consider a form like follows:

  public function buildForm(array $form, FormStateInterface $form_state): array {

    $form['message'] = [
      '#type' => 'tableselect',
      '#title' => $this->t('Test Table Select'),
      '#required' => TRUE,
      '#header' => ['1','2','3'],
      '#options' => [
        '1' => ['a','b','c'],
        '2' => ['d','e','f'],
        '3' => ['g','h','i'],
      ],
      '#multiple' => TRUE,
    ];

    $form['actions'] = [
      '#type' => 'actions',
      'submit' => [
        '#type' => 'submit',
        '#value' => $this->t('Send'),
      ],
    ];

    return $form;
  }

If you examine the resultant form using a tool like the drupal editoria11y module ( https://www.drupal.org/project/editoria11y β†’ ) or the industry standard axe dev tools, it reports an accessibility error.

Image from axe dev-tools:

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
JavascriptΒ  β†’

Last updated about 12 hours ago

Created by

πŸ‡¨πŸ‡¦Canada mgifford Ottawa, Ontario

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • Accessibility

    It affects the ability of people with disabilities or special needs (such as blindness or color-blindness) to use Drupal.

  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024