WebAIM - Web Accessibility In Mind

E-mail List Archives

Thread: Using "-1" for table column and row count

for

Number of posts in this thread: 2 (In chronological order)

From: Sumit Patel
Date: Wed, Oct 30 2024 5:44AM
Subject: Using "-1" for table column and row count
No previous message | Next message →

Hai all,

I'm writing to get some clarification on the usage of the aria-colcount and
aria-rowcount attributes in data tables, specifically when to use the value
"-1".
I understand that "-1" is generally used for dynamic content where the
total number of rows or columns is unknown at the time the page loads
(e.g., infinite scrolling, paginated tables). However, I'm unsure about
appropriate use cases in the following scenarios:
Scenario 1:
• A table with 2 columns (news headlines and date/time) and 21 rows (always)
• Data is dynamic, with the last 5 rows removed and new 5 rows added at the
top every few minutes
• Screen reader announces the total number of rows as "-1"
Question: Is using "-1" appropriate here, even though the total row count
is always 21?
Scenario 2:
• A table below a filter section
• The table content changes only when the user interacts with the filters
(not dynamically on its own)
• Screen reader announces the total number of rows as "-1"
Question: Is using "-1" appropriate here, since the table content isn't
truly dynamic, but user-controlled?
Scenario 3:
• A table with 30 rows and 100+ columns
• Initially, only 10 columns are displayed. User scrolls right to see
additional columns (lazy loading)
• Screen reader announces the total number of columns as "-1"
Question: Is using "-1" appropriate here for columns, considering lazy
loading reveals more columns on scroll?
Thanks in advance for your insights!

Regards,
Sumit.

From: Patrick H. Lauke
Date: Wed, Oct 30 2024 6:04AM
Subject: Re: Using "-1" for table column and row count
← Previous message | No next message

My understanding of this (admittedly not played around with this much):
the "-1" value indicates that the number of rows or columns should not
rely on the user agent's calculation, and should be used when the total
is unknown.

Scenario 1: if you do already know in advance how many there will be
(like your example of there always being 21 news items), then use that
value instead - even if the items aren't fully loaded in the DOM yet and
will only be loaded in dynamically. That way, the table *will* be
announced as having X items, regardless of what is currently in the DOM
or not)

Scenario 2: I would not use any row count attribute here, as the table
will update after user interaction only (and then after it's updated you
can likely rely on the user agent's own calculation of how many rows
there are)

Scenario 3: if you don't know for sure how many total columns there will
be, and they're not all present in the DOM yet, "-1" seems appropriate here.

P
--
Patrick H. Lauke

* https://www.splintered.co.uk/
* https://github.com/patrickhlauke
* https://flickr.com/photos/redux/
* https://mastodon.social/@patrick_h_lauke