Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TreeGrid accessibility: Improve browser support for Left Arrow focus to parent row in child row #38639

Merged
merged 1 commit into from
Feb 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/components/src/tree-grid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ function TreeGrid(
}
// If a row is focused, and it is collapsed, moves to the parent row (if there is one).
const level = Math.max(
parseInt( activeRow?.ariaLevel ?? 1, 10 ) - 1,
parseInt(
activeRow?.getAttribute( 'aria-level' ) ?? 1,
10
) - 1,
1
);
const rows = Array.from(
Expand All @@ -120,7 +123,10 @@ function TreeGrid(
const currentRowIndex = rows.indexOf( activeRow );
for ( let i = currentRowIndex; i >= 0; i-- ) {
if (
parseInt( rows[ i ].ariaLevel, 10 ) === level
parseInt(
rows[ i ].getAttribute( 'aria-level' ),
10
) === level
) {
parentRow = rows[ i ];
break;
Expand Down