Sortable Table Column Mad Libs

Visually and functionally sortable column headers on tables are straightforward (I have a post on that coming soon). However, making them accessible can be a bit frustrating. To clarify, making them accessible to screen readers is frustrating.

There are two critical areas where screen readers fall down here: lack of technology consistency in how sortable columns are announced, and failure to announce when the sort is performed. For this post I am going to focus on the former.

Last month I ran a Twitter poll asking screen reader users to choose the most useful column labeling technique from four options, being careful not to assign parameters.

The responses I got back (email, chats, real life) were more valuable than that highly scientific poll. Users talked about when one option is too verbose, when another is too simple, how context matters, how much detail they need in instructions, and what they expect based on their screen reader.

Given the variety in how screen readers expose the parts of sort controls, how libraries and frameworks think they should work, and how few developers have the comfort or familiarity with ARIA / HTML and screen readers, I opted to create a tool. For me.

Screen shot of the form in my embedded example I waded into screen reader and browser pairings, figured out how they piece together the strings they announce to users, and built a form that will show you that output as plain text. It also shows what the HTML construct might look like for the parameters you provide.

I also confirmed you no longer need role="columnheader" to make screen readers notice the aria-sort attribute.

You will see it is a craven chaos of color, but that is my effort to color-code the constituent parts of each string. Think of this as another attempt to help sighted developers understand how their code impacts screen reader announcement, similar to the video I made for disclosure widgets.

The interaction I used to build this is strictly from table navigation commands on desktop (generally Ctrl + Alt + arrows on Windows and Ctrl + Option + arrows on macOS) and swiping on mobile. I also do not bother to note that some combinations will announce “row one” as you first enter the column header row. Plus other quirks. Think of this tool as generating an average output.

Activating a sort control results in no announcement in TalkBack, NVDA, or VoiceOver on macOS. VoiceOver on iOS and iPadOS repeats the column header information while also adding the row number. JAWS would sometimes announce sorting only when I activated it with Space, but then it would report the prior column as being sorted. So. Yeah.

My test suite:

Try Sortable Column Mad Libs in debug mode if you want to avoid looking at my truly awful script.

See the Pen Sortable Column Mad Libs by Adrian Roselli (@aardrian) on CodePen.

If you see something amiss, let me know. If you find it useful, let me know. It is not perfect. In time I may add more pairings, or at least when I find things deviate from what I logged above.

No comments? Be the first!

Leave a Comment or Response

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>