-
-
Notifications
You must be signed in to change notification settings - Fork 659
Description
Environment information
N/A
Rule name
lint/a11y/noNoninteractiveTabindex
Playground link
Expected result
Both treegrid and grid are described to work like spreadsheets on the web, where data can be edited and individual cells can be focused within and navigated using arrow keys.
Treegrid takes it one step further and allows expanding/collapsing of rows and columns like a tree.
So when trying to implement focus behavior, this throws an error when it shouldn’t:
// The HTML element div is non-interactive. Do not use tabIndex. (❌ Incorrect)
<div role="gridcell" tabIndex={0}>
~~~~~~~~~~~~
This conflicts with the recommended behavior of treegrid children:
Right Arrow
If focus is on a collapsed row, expand the row. …
In other words, a gridcell MUST be focusable when inside a treegrid if it’s expandable (via tabIndex
), and also MUST be able to receive other keyboard commands.
lint/a11y/noNoninteractiveTabindex
is correct in other instances, so it seems this is only a problem with grid and treegrid children.
Other notes
- The
useSemanticElements
rule does apply to this example but is irrelevant; noNoninteractiveTabindex still raises the same errors - Worth noting that, yes, by default many gridcells (and related roles) aren’t interactive, this issue is in certain scenarios they ARE REQUIRED to be
- The “roving tabindex” approach is optional here (where only the focusable element receives
tabIndex={0}
and everything else getstabIndex={-1}
), but also doesn’t affect the outcome
Code of Conduct
- I agree to follow Biome's Code of Conduct