Problem/Motivation

Several form controls on the Views exposed filters grouped form are missing accessible names.

Steps to reproduce (2 cases)

Case 1: Non-numerical filters
  1. Install drupal using the Umami profile (drush si -y demo_umami).
  2. Go to /en/admin/structure/views.
  3. Edit the "Content" view.
  4. Under "Filter criteria", click "Content: Published (grouped)".
  5. Scroll down to the grouped filter settings
  6. With the dialog still open, run a check with the Axe or Accessibility Insights extensions. There are 5 elements that are missing labels.

Screenshot of errors.

Case 2: Numerical filters
  1. Install with Umami or Standard profile.
  2. Go to /en/admin/structure/views (with Umami profile) or /admin/structure/views (with Standard profile).
  3. Edit the "Content" view.
  4. Under the "Filter criteria" section, click "Add".
  5. In the list of fields that appears, select "ID" (in the Content category).
  6. Click "Add and configure filter criteria".
  7. Select "Expose this filter to visitors, to allow them to change it".
  8. Select "Grouped filters"
  9. Scroll down, and change one of the group row operators to "Is between".
  10. With the dialog still open, run a test with Axe or Accessibility Insights extensions.

Screenshot of the affected elements highlighted by accessibility insights.

Proposed resolution

  1. Ensure that the elements have #title properties with appropriate text.
  2. Hide the labels visually with '#title_display' => 'invisible'.

Remaining tasks

User interface changes

  • Visually, no changes.
  • Visually-hidden accessible names are added for the affected elements. These will be perceivable for users of assistive technology.

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-2608212

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.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

lendude’s picture

StatusFileSize
new12.21 KB

This is still an issue. Tried playing around with this but just adding a title to the 'group default' for example leads to this gem:

So unfortunately the build up of the HTML of that form makes this more difficult than one might expect.

lendude’s picture

In case somebody wants to take a stab at this, the form can be found in \Drupal\views\Plugin\views\filter\FilterPluginBase::buildExposedFiltersGroupForm

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Bug Smash Initiative

Could someone provide steps to reproduce this?

I'm not seeing the popup from the screenshot in the issue summary.

lendude’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active

Added steps to reproduce

smustgrave’s picture

Believe this could be a symptom of
https://www.drupal.org/project/drupal/issues/2839344

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

mgifford’s picture

Issue tags: +wcag332

Tagging for 3.3.2

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

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

kentr’s picture

Issue tags: +wcag412, +Needs tests

It looks like the Remove checkboxes have been fixed.

I found other cases: The textfields for numerical filters. I think it's called the "in operator".

I think I have a fix, and will update the IS and create an MR. I think this is testable in Nightwatch.

kentr’s picture

I was wrong about the Remove checkboxes. They are still missing labels.

The strange thing is that it looks like they're not supposed to be visible. There's this comment in the code, and they don't appear when the admin theme is Stark.

// No title is given here, since this input is never displayed. It is
// only triggered by JavaScript.

kentr’s picture

Yeah, the Remove checkboxes have display: none in the views_ui module and in Claro.

Claro then overrides that with .form-boolean. It's probably an accident because it's a generic selector. I haven't checked Gin.

I think there's a bigger issue of whether they should be visible at all, but I'm planning to give them a hidden label due to #933004: Test that all form elements have a #title for accessibility (which will require a #title property).

kentr’s picture

Title: Content: Publishing status (grouped) is missing labels for inputs » Elements on grouped exposed filters configuration form are missing accessible names
Issue summary: View changes
Status: Active » Needs review
Issue tags: -Needs tests
StatusFileSize
new104.84 KB

The Remove checkboxes are also visible in Gin. Based on #3375806-14: Views 'Rearrange' dialog show the 'Remove' checkbox, which should be visually hidden, it looks like they should be hidden with the js-hide class in another issue.

smustgrave’s picture

Does this need to be a nightwatch test or can it be javascript? Just because I've heard that nightmatch may eventually be removed.

kentr’s picture

To be robust, it really needs to check for the computed accessible names.

It would be possible to check the underlying HTML (like looking for label elements), but to me that's indirect because the end goal is the computed name that users perceive, not the specific HTML.

It's also more brittle because tests could fail or have false positives if the page output has another naming method for some reason. Tests would have to keep up with the HTML changes. They could, but that would bring its own maintenance problems...

AFAIK, our current functional javascript tests can't compute the accessible name, and it's not easy to do it with vanilla JS.

Nightwatch can do it for individual elements with the getAccessibleName() function, but a full Axe scan will check the whole page.

I did it this way because it looks in line with #2857808: Automate Accessibility Checks for Core (esp Phase 2), and Views / Views UI don't have good coverage. It's a starting point for adding more complex cases.

Even if "standard" Nightwatch tests get replaced there's no good alternative for Axe tests until #3338664: Migrate Nightwatch Axe tests to PHPUnit lands.

I have to admit that I don't love the specifics of the test, though. It would be better if it used findByLabelText() in the setup for the page. It would probably be more robust if it created a simple test view instead of depending on an existing view that comes with the installation profile. But these won't matter if the test is going to be converted to a functional javascript test with #3338664: Migrate Nightwatch Axe tests to PHPUnit.

smustgrave’s picture

Not saying it has to change but isn't this now just checking for labels? There existing javascript or functional test that could be expanded for this.

kentr’s picture

Not saying it has to change but isn't this now just checking for labels? There existing javascript or functional test that could be expanded for this.

The computed accessible names could come from label elements, but they could also be established in other ways like aria-label or aria-labelledby.

PHPUnit / Functional Javascript can't get computed accessible names yet, to my knowledge. The computation is complex, so using Axe takes advantage of its accessible name computation.

kentr’s picture

There existing javascript or functional test that could be expanded for this.

I realize that I missed "javascript" here...

The navigation module has its own "a11y" test, and it's in a separate file from the other JS tests. Looks like that was done in #3393400: Implement Nightwatch tests for Navigation module.

I was trying to follow that precedent for views_ui.

smustgrave’s picture

Will leave for others but personally I think less nightwatch the better

kentr’s picture

FWIW, there were some changes related to this already made on #933004: Test that all form elements have a #title for accessibility.

That MR includes a check for empty #title properties, which is catching most of the remaining cases from this issue (by way of ExposedFormUITest.php).

I confirmed by applying the rest of the changes here in ::buildExposedFiltersGroupForm(), and the tests went green. So it functions as a rough test that the changes were made.

It does not catch the missing name for the first item in the table, because that is removed in a theme function.

It may make sense to roll the remaining PHP changes from this issue into #933004: Test that all form elements have a #title for accessibility and closing this one as a duplicate.

If this strategy is palatable, I'll make the changes in that MR.

kentr’s picture

Status: Needs review » Needs work

Also, the name for the radio button in the top-left of the table next to "" should probably be "Any", if it isn't already.

I made a comment on the MR to check this.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

kentr’s picture

kentr’s picture

Issue summary: View changes
kentr’s picture

Issue summary: View changes
kentr’s picture

kentr’s picture

Issue summary: View changes
Status: Needs work » Needs review

As part of splitting up #933004: Test that all form elements have a #title for accessibility, I've refreshed the MR.

I removed the Nightwatch test and am hoping we can skip the addition of tests for now since the goal of #933004: Test that all form elements have a #title for accessibility is to add a single test for all cases.

The current failing test looks unrelated and passes locally (albeit with unrelated deprecation notices). I created a random test failure issue.

Would someone please rerun the failing job? I can't.

kentr’s picture

Issue tags: +Needs manual testing
gwenweb’s picture

Status: Needs review » Reviewed & tested by the community

I manually applied the patch to a Drupal 11 environment (I couldn't run the actual branch, it requires PHP >= 8.5 which DDEV doesn't support yet). The code paths are identical, so I believe the results hold, but please factor in this limitation.

Test setup: built-in content view, grouped exposed filter on status, tested via the filter configuration dialog in Views UI.

Results verified via DevTools inspection:

Operator <select> label now present in DOM, correctly associated:

<label for="..." class="form-item__label visually-hidden">Operator</label>
<select id="..." name="options[group_info][group_items][1][operator]">...</select>

Remove checkbox label now present:

<label for="views-removed-1" class="form-item__label visually-hidden">Remove</label>
<input type="checkbox" id="views-removed-1" ...>

"Any" radio (Default column) label now present:

<label for="..." class="form-item__label visually-hidden">- Any -</label>
<input type="radio" value="All" checked="checked">

I hope this is useful, happy to be corrected on anything I missed.