Problem/Motivation

In #1342760: Add aria-sort to table sort we added the aria-sort attribute to our sortable tables. You can find this in the headers of the recent log messages table at admin/reports/dblog, for example.

It would be good to add aria-sort to Views table displays too. The previous issue actually predates the official VDC initiative, and it seems that the views_view_table theme hook doesn't use tablesort_header().

Proposed resolution

Include the aria-sort attribute with the Views table display plugin.

Remaining tasks

  • Add aria-sort to Views table headers - DONE, patching template_preprocess_views_view_table()
  • Tests - confirm presence + direction of aria-sort attribute.

User interface changes

No visual changes.
Adds aria-sort attribute to table headers for assistive tech.

API changes

None.

Data model changes

None.

Issue fork drupal-2782111

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

andrewmacpherson created an issue. See original summary.

andrewmacpherson’s picture

Issue summary: View changes
andrewmacpherson’s picture

Issue summary: View changes
mgifford’s picture

Good catch!

msankhala’s picture

Assigned: Unassigned » msankhala
msankhala’s picture

Here we go with patch which adds aria-sort attribute to views table output.

vermauv’s picture

Status: Active » Needs review

Patch #6 Applied on branch 8.3.x-dev, Works fine.

msankhala’s picture

Assigned: msankhala » Unassigned
andrewmacpherson’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs tests

Thanks @msankhala.

The patch in #6 provides the functionality we need. The markup is correct, and I've tested it with NVDA screenreader + IE9 on Win7. The direction from the aria-sort attribute is correctly announced, and it matches the behaviour of the non-Views tablesort (in the recent log messages page). I expect this will be fine for all browser/screen reader combinations that support aria-sort.

This would benefit from tests before we RTBC it. The existing tests for tablesort don't appear to have coverage for aria-sort attributes, so there's nothing to crib from :-(

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.

andrewmacpherson’s picture

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.

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.

themusician’s picture

StatusFileSize
new1.26 KB

Reroll of the original patch to work on 9.4.x. Will look into building a proper test to go along with this work.

carlygerard’s picture

StatusFileSize
new3.89 KB

Adding new aria-sort test to check the th contains a corresponding aria-sort value based on sort setting.

themusician’s picture

StatusFileSize
new4.03 KB

Another attempt at the patch file.

ravi.shankar’s picture

StatusFileSize
new3.55 KB
new648 bytes

Fixed Drupal CS issue of patch #24.

yogeshmpawar’s picture

Status: Needs work » Needs review
StatusFileSize
new3.55 KB
new620 bytes

Updated patch will resolve CSpell error.

Status: Needs review » Needs work

The last submitted patch, 26: 2782111-26.patch, failed testing. View results

carlygerard’s picture

StatusFileSize
new1.25 KB

Should remove row_header key that entered in #24.

carlygerard’s picture

StatusFileSize
new3.8 KB
new370 bytes

Git issues with previous patch file, includes now test file and include, along with interdiff.

carlygerard’s picture

StatusFileSize
new5.39 KB
new1.04 KB

Changes method of testing if aria-sort attribute is set to ascending by using elementAttributeContains().

carlygerard’s picture

StatusFileSize
new7.05 KB

Fix phpcs spacing issues in comment with update in #30.

themusician’s picture

StatusFileSize
new2.83 KB

Updating the CSS selector as the AJAX base table uses Views Bulk Operations (VBO) which meant the first th was not in fact the title header and not sortable.

themusician’s picture

Hmm... any ideas? That final selector works when accessing the table via the browser console. Is there some sort of additional delay needed for the AJAX click?

It really seems like this should be working properly.

 $page->clickLink('Title');
 $session_assert->assertWaitOnAjaxRequest();
 $session_assert->elementAttributeContains('css', 'th.views-field-title', 'aria-sort', 'ascending');
themusician’s picture

StatusFileSize
new4.07 KB

Somehow uploaded only the test. My apologies.

themusician’s picture

Status: Needs work » Needs review

A passing test. Setting to Needs review.

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.

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.

themusician’s picture

StatusFileSize
new4.11 KB

A 10.x-dev compatible patch

nivethasubramaniyan’s picture

StatusFileSize
new967 bytes
new2.21 KB

Fixing CCF

themusician’s picture

Thank you @NivethaSubramaniyan

gaurav-mathur’s picture

Verified and tested patch#39 on Drupal 10.1.x-dev and its working fine.
Patch applied successfully.
Thank You.

prasanth_kp’s picture

StatusFileSize
new32.53 KB
new33.91 KB

Thank you @NivethaSubramaniyan #39 Applied patch on Drupal 10.1.x-dev and it is working fine.

themusician’s picture

Created a new fork and added back in the test that verifies the new sort works properly. That looks to have been accidentally dropped during the reroll.

Please test again so that perhaps this issue can be changed to Reviewed and Tested by the Community (RTBC).

mgifford’s picture

Issue tags: +wcag412

Adding tag for WCAG 4.1.2

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

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

Reviewing MR 3222 as that seemed the more correct one.

Rebased the branch but there are CI failures that will have to be addressed

Hiding the files to avoid confusion as the issue is being fixed in an MR now.

Removing credit from myself for the rebase.

pooja saraah’s picture

StatusFileSize
new3.63 KB

Fixed failed commands on #48
Attached patch against Drupal 10.1.x

smustgrave’s picture

Hiding #50 as the issue is being addressed in the MR

prem suthar’s picture

StatusFileSize
new3.63 KB

Try To Fix the #50 Patch.

prem suthar’s picture

StatusFileSize
new3.62 KB

Fix The Custom CMD Patch Of mine.

carlygerard’s picture

StatusFileSize
new3.9 KB

New patch file to fix failing tests. Suggested to use patch files for tests since Gitlab branch testing seems stuck in the composer loop.

smustgrave’s picture

Can't you submit the changes to the MR? 3222 is having an issue because the code needs tweaked.

Think switching back n forth between MRs and patches causes noise and could delay this. just fyi.

themusician’s picture

Starting at comment #54 patches have started to be used. The existing MR 3222 claims it is mergeable but when one tries, it fails with a composer error.

That composer error seems related to a gitlab infrastructure snafu that occurred around the time the MR was updated. Now it seems stuck.

carlygerard’s picture

StatusFileSize
new5.35 KB

Refactored #54 patch with drupalcs reported issues fixed. Patch file for now until Gitlab composer issue for MR 3222 is addressed.

themusician’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests

Removing the tests tag as they have been added.

But instead of adding a new file and bootstrapping a new instance think it would be best to extend an existing test.

Was searching around NodeAdminTest::testContentAdminSort. "Tests that the table sorting works on the content admin pages." think we could just add a line or two checking for the aria-label.

Verified this is working on Drupal 10.1 with a standard install.
Went to the admin content page
Verified I see aria-sort on the updated column
Clicked the column and aria-sort changed
Clicked a different column and aria-sort moved.

Thanks

carlygerard’s picture

Status: Needs work » Needs review
StatusFileSize
new2.84 KB

Patch moves the aria-sort test into the existing NodeAdminTest PHP test as @smustgrave suggested, and removes the aria-sort specific test. Needs review to check if ->elementAttributeContains() method is enough for the testing needed.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Much better!

Please include an interdiff with the patches though.

carlygerard’s picture

StatusFileSize
new3.88 KB

Interdiff between patches #57 and #60. Thanks for the reminder @smustgrave.

  • catch committed 49167644 on 10.1.x
    Issue #2782111 by theMusician, CarlyGerard, smustgrave, msankhala,...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 4916764 and pushed to 10.1.x. Thanks!

Status: Fixed » Closed (fixed)

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