aria icon indicating copy to clipboard operation
aria copied to clipboard

aria-sort should be allowed on multiple columns

Open jnurthen opened this issue 9 years ago • 14 comments

aria-sort states "For each table or grid, authors should apply aria-sort to only one header at a time."

It is relatively common in large tables to allow multiple columns to be used in the sort criteria. Sort by column 1 then sort by column 2 etc. We should be able to use aria-sort for this.

jnurthen avatar Mar 04 '16 21:03 jnurthen

See also: #582

hartman avatar Jun 29 '17 14:06 hartman

Adding the "Agenda" label: I don't think this needs to be an ARIA 2.0 thing. Tables exist in the wild that have this functionality, and I don't believe it would be hard to support this in ATs or browsers.

joanmarie avatar Aug 10 '20 18:08 joanmarie

@jnurthen found an example that uses shift-click to sort multiple columns: https://datatables.net/examples/basic_init/multi_col_sort.html

screen shot of data table header row with multiple chevrons indication multi-column sort

I don't think this is a particularly clear user interface—Of the sorted columns, which has priority?—but since it's being used in sites, I see no issue with allowing aria-sort on multiple elements.

cookiecrook avatar Aug 13 '20 23:08 cookiecrook

Quick brainstorm: the "multi-column sort order/priority" problem might be solved as a new attribute aria-sortorder: null | 1 | 2 | n… or as a variant value on the existing attr, maybe: aria-sort="ascending second" or aria-sort="ascending 2"... Musing. Not thoroughly considered and no strong preference.

cookiecrook avatar Aug 13 '20 23:08 cookiecrook

I don't think this is a particularly clear user interface—Of the sorted columns, which has priority?

In the applications I know, this is very clearly marked with numbers in the column headings

new attribute aria-sortorder or as a variant value on the existing attr, maybe: aria-sort="ascending second"

I would prefer the new attribute because the second variant differs greatly from the current ARIA standard (one attribute for two different value types: name and number)

JAWS-test avatar Aug 14 '20 01:08 JAWS-test

In the applications I know, this is very clearly marked with numbers in the column headings

Screen shots and/or more specific references to those may help. I don't think I've ever seen any, and no one else on the call could think of examples that conveyed the order.

cookiecrook avatar Aug 25 '20 02:08 cookiecrook

Screen shots and/or more specific references to those may help

I am not allowed to publish screenshots of internal company applications, but a google search for "table multiple sort" finds many examples, e.g. https://blog.ofanitguy.com/2014/03/06/ls2013-html-enhancing-table-control-with-column-sort-and-filters/

JAWS-test avatar Aug 31 '20 09:08 JAWS-test

As a matter of fact, multiple sorts in tables are not rare in real life business applications.

stes-acc avatar Sep 17 '20 12:09 stes-acc

@stes-acc do you want to take ownership of this?

jnurthen avatar Mar 01 '21 23:03 jnurthen

Yes

stes-acc avatar Mar 02 '21 07:03 stes-acc

I have a prototype of a table where more than one column can be sorted at a time. I have multiple clients whose data tables do this. I cannot share the client examples, but I can share the prototype, variants of which are in user-facing sites:

  • Demo: https://cdpn.io/pen/debug/poexGPV
  • Explainer: https://adrianroselli.com/2021/06/multi-column-sortable-table-experiment.html

Visually, it puts numbers on the column headings to indicate which column is sorted first, and then next, and so on.

Programmatically, since there is no way to indicate a ranking or priority, I append "priority #" to the accDesc for the column. It is a bit wordy, but seems to have so far gotten the point across.

In the attached screen shot, I am showing the Year column is sorted descended, and then Title is sorted ascending, and then Author is sorted descending.

On sort in this case, the live region announced (Year was already apparent from the control name): "sorted down, Author descending priority 3, Title ascending priority 2"

For the programmatic bits once it is in the state shown in the image:

  • The accName of the Year column is "Year".
  • Its accDesc is "sort priority 1"
  • The button's accName is "Year".
  • The button has no accDesc.
  • This pattern applies to the other columns.
A table of 6 columns with the first three columns sorted; the column headers of those three include an offset circle with a number and arrows either pointing up or down.

I am not saying this is the right way to handle it. It does show a representation of what is in the wild and identifies gaps in how it should convey ranking/priority.

aardrian avatar Jun 28 '22 22:06 aardrian

Just a quick note as a library author to say that aria-sortorder would be easy to implement. I'm happy to prototype things in development versions of DataTables if any accessibility software devs are interested in trying things out.

AllanJard avatar Nov 14 '23 13:11 AllanJard

@aardrian would you want to take this on by any chance?

pkra avatar May 13 '24 16:05 pkra

@pkra

@aardrian would you want to take this on by any chance?

Yes.

aardrian avatar Aug 17 '24 12:08 aardrian

Thursday 29 May 2025, we had a deep dive.

I made slides (should be accessible, and the embedded video has captions), and the slides include examples with my own approach (neither good nor bad, just an approach): ARIAWG-deep-dive_table-sort.pptx

I believe there is a recording of the call instead of minutes.

Broad agreement:

  • ARIA does not forbid sorting on multiple columns.
  • If exposed programmatically, a new property is preferred over adding a value to an existing property.
  • The method for sorting is out scope of this issue (whether a button in the column header or a control outside the table).

Undecided:

  • Whether or not ARIA needs to expose a sort priority.
  • Or whether authors can do it sufficiently with text, accNames, other cues (with my caution against CSS generated content).

Next steps:

  • Survey current support for announcing sort both when performing sort and when navigating column. My recent testing showed:
    • NVDA, JAWS, Narrator, and VoiceOver/iPadOS support.
    • TalkBack and VoiceOver on macOS do not support.
  • Link to open bugs (and file if necessary)
  • Find any related issues.
  • Find out if screen reader vendors show any interest.

Related but out of scope:

  • Wikipedia uses Shift to sort more than one column, but does not expose the priority in any way: https://en.wikipedia.org/wiki/Help:Sortable_tables#Secondary_key_and_multi-key_sorting
  • Open-UI discussed asking UAs to natively support sorting, but does not discuss sorting multiple columns and is also marked stale: https://github.com/openui/open-ui/issues/800

aardrian avatar May 30 '25 16:05 aardrian