Use tabindex="0"
whenever .table-responsive*
is used
#38971
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds
tabindex="0"
whenever.table-responsive*
s are used in the documentation or examples.This ensures that the area is focusable with the keyboard (on Chrome for instance) when the tables don't fit and render a scrollbar.
Motivation & Context
Boosted runs axe tests automatically. With the latest
axe-core
version (4.7.2
), new tests have their impacts changed to serious and are now caught by ourpa11y-ci
:Here's the report on our side (which is the same as in Bootstrap):
This is also linked to #38963 because
.table-responsive
usesoverflow: auto
.To understand the error, please go to https://codepen.io/julien-deramond/pen/bGQxKej with Chrome and you'll see that without tabindex="0" the area isn't focusable with the keyboard. So the idea to fix it is to add this tabindex="0" where needed as explained by https://dequeuniversity.com/rules/axe/4.7/scrollable-region-focusable?application=axeAPI.
You can also go directly to https://getbootstrap.com/docs/5.3/content/tables/#always-responsive in mobile mode and play with focus on Firefox and Chrome.
We can see that Firefox is smarter (probably because of
-webkit-overflow-scrolling: touch
) and allows the area to be focused only when needed.However, for Chrome, there's no way (to my knowledge) to differentiate when there's a scroll or not. So the idea here is to use
tabindex="0"
all the time. It means that even in desktop mode, the keyboard focus is on the tables even if there's nothing to focus really. That's where I have doubts, but I got the feeling that having too much focus is better than not having it...More context on Boosted side: Orange-OpenSource/Orange-Boosted-Bootstrap#2162 (comment)
Type of changes
Checklist
npm run lint
)Live previews
{{< bs-table >}}
(that's a lot)