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.
| Comment | File | Size | Author |
|---|---|---|---|
| #62 | interdiff_57_60.txt | 3.88 KB | carlygerard |
| #60 | 2782111-60.patch | 2.84 KB | carlygerard |
| #57 | 2782111-57.patch | 5.35 KB | carlygerard |
| #54 | 2782111-54.patch | 3.9 KB | carlygerard |
| #53 | 2782111-53.patch | 3.62 KB | prem suthar |
Issue fork drupal-2782111
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:
- 2782111-46
changes, plain diff MR !3222
- 2782111-add-aria-sort-attribute
changes, plain diff MR !3202 /
changes, plain diff MR !3203
Comments
Comment #2
andrewmacpherson commentedComment #3
andrewmacpherson commentedComment #4
mgiffordGood catch!
Comment #5
msankhala commentedComment #6
msankhala commentedHere we go with patch which adds
aria-sortattribute to views table output.Comment #7
vermauv commentedPatch #6 Applied on branch 8.3.x-dev, Works fine.
Comment #8
msankhala commentedComment #9
andrewmacpherson commentedThanks @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 :-(
Comment #14
andrewmacpherson commentedComment #15
andrewmacpherson commentedComment #22
themusician commentedReroll of the original patch to work on 9.4.x. Will look into building a proper test to go along with this work.
Comment #23
carlygerardAdding new aria-sort test to check the th contains a corresponding aria-sort value based on sort setting.
Comment #24
themusician commentedAnother attempt at the patch file.
Comment #25
ravi.shankar commentedFixed Drupal CS issue of patch #24.
Comment #26
yogeshmpawarUpdated patch will resolve CSpell error.
Comment #28
carlygerardShould remove row_header key that entered in #24.
Comment #29
carlygerardGit issues with previous patch file, includes now test file and include, along with interdiff.
Comment #30
carlygerardChanges method of testing if aria-sort attribute is set to ascending by using elementAttributeContains().
Comment #31
carlygerardFix phpcs spacing issues in comment with update in #30.
Comment #32
themusician commentedUpdating 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.
Comment #33
themusician commentedHmm... 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.
Comment #34
themusician commentedSomehow uploaded only the test. My apologies.
Comment #35
themusician commentedA passing test. Setting to Needs review.
Comment #38
themusician commentedA 10.x-dev compatible patch
Comment #39
nivethasubramaniyan commentedFixing CCF
Comment #40
themusician commentedThank you @NivethaSubramaniyan
Comment #41
gaurav-mathur commentedVerified and tested patch#39 on Drupal 10.1.x-dev and its working fine.
Patch applied successfully.
Thank You.
Comment #42
prasanth_kp commentedThank you @NivethaSubramaniyan #39 Applied patch on Drupal 10.1.x-dev and it is working fine.
Comment #43
themusician commentedCreated 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).
Comment #47
mgiffordAdding tag for WCAG 4.1.2
Comment #49
smustgrave commentedThis 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.
Comment #50
pooja saraah commentedFixed failed commands on #48
Attached patch against Drupal 10.1.x
Comment #51
smustgrave commentedHiding #50 as the issue is being addressed in the MR
Comment #52
prem suthar commentedTry To Fix the #50 Patch.
Comment #53
prem suthar commentedFix The Custom CMD Patch Of mine.
Comment #54
carlygerardNew patch file to fix failing tests. Suggested to use patch files for tests since Gitlab branch testing seems stuck in the composer loop.
Comment #55
smustgrave commentedCan'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.
Comment #56
themusician commentedStarting 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.
Comment #57
carlygerardRefactored #54 patch with drupalcs reported issues fixed. Patch file for now until Gitlab composer issue for MR 3222 is addressed.
Comment #58
themusician commentedComment #59
smustgrave commentedRemoving 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
Comment #60
carlygerardPatch 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.Comment #61
smustgrave commentedMuch better!
Please include an interdiff with the patches though.
Comment #62
carlygerardInterdiff between patches #57 and #60. Thanks for the reminder @smustgrave.
Comment #64
catchCommitted 4916764 and pushed to 10.1.x. Thanks!