Accessibility issue with FixedHeader in data tables containing links
Accessibility issue with FixedHeader in data tables containing links
Link to test case: https://live.datatables.net/qacedomo/1
Debugger code (debug.datatables.net): N/A
Error messages shown: N/A
Description of problem:
I have a data table that contains links. We are trying to get the data table compliant with the following WCAG 2.2 rule: 2.4.11 Focus Not Obscured (https://www.w3.org/WAI/standards-guidelines/wcag/new-in-22/#2411-focus-not-obscured-minimum-aa ). What is happening in the test case above is temporary obstruction of the rows when tabbing backward with the keyboard.
To reproduce the issue using the test case above, tab through the data table until you reach the bottom row and then tab backwards. Notice that as you tab backwards, rows you tab to are temporarily hidden behind the Fixed Header - this makes our data table implementation not compliant with the above WCAG 2.2 rule.
Does anyone have an idea on how to improve the accessibility of this data table? One idea I have is to use JavaScript to detect the position of the element user is tabbing to and then automatically scroll user to a position that they can fully see the row, but wanted to see if other people had other ideas or maybe already have a working solution to this issue.
Note: what I also noticed is that behavior in Firefox is different than in Chrome, but in both browsers rows temporarily are obstructed by FixedHeader during tabbing backwards.
Thanks in advance for any help on this.
This question has an accepted answers - jump to answer
Answers
I think you are right - a Javascript
focus
event handler on all elements in the table would be needed for this. Get the position of the currently focused element, see if it is under the fixed header or not, and reposition the scrolling of the page to make it visible.It would be quite possible. I'd welcome a pull request from yourself or anyone else who is able to work on this.
Allan
allan,
Thanks for the answer. I'll see if I can work on this when I get a chance.
Wondering if anyone else has some ideas?
I have worked a bit on a solution. The first draft I have is below. This code will scroll user up 100 pixels when the position of the tabbed a tag is within 70 pixels from the top.
//helper method to determine position of the element relative to view
function getViewportPosition(element) {
const rect = element.getBoundingClientRect();
Nice one! Thanks for sharing that with us.
Allan
You bet!
Just wanted to share our final solution. We opted out to do the following:
Example:
And then add this code after the data table initialization:
Awesome - thank you for the follow up!
Allan