The current implementation uses aria-label to override the default screen reader behavior of reading aloud the text contents: https://github.com/elastic/eui/blob/master/src/components/table/table_header_cell.js#L61
This presents two problems:
- It means that providing a node as
children will cause the screen reader to read something like "Sort [Object object] ascending".
- As the user traverses the cells in the table body, the screen reader reads aloud the associated column header to help the user orient themselves. This means the user hears "Sort {column title} ascending/descending" for each cell they navigate to, which is confusing to hear.
I think one solution would be to use the sortIcon to provide screen-reader-specific sort information. Instead of conditionally rendering it, we could always render it but wrap it in EuiScreenReaderOnly when the column isn't being sorted on. We could then put aria-label={Click to sort ascending/descending} on the sort icon, which will be read aloud after the column text content is read.
The current implementation uses
aria-labelto override the default screen reader behavior of reading aloud the text contents: https://github.com/elastic/eui/blob/master/src/components/table/table_header_cell.js#L61This presents two problems:
childrenwill cause the screen reader to read something like "Sort [Object object] ascending".I think one solution would be to use the
sortIconto provide screen-reader-specific sort information. Instead of conditionally rendering it, we could always render it but wrap it inEuiScreenReaderOnlywhen the column isn't being sorted on. We could then putaria-label={Click to sort ascending/descending}on the sort icon, which will be read aloud after the column text content is read.