Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

check if element exists before focusing added #2056

Merged
merged 3 commits into from
Feb 29, 2024
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,16 @@ const CompactInteractiveList = (props) => {

const focusCell = ({ row, cell }) => {
// add 1 to the row number to accommodate for hidden header
const focusedCellElement = listRef.current.children[row + 1].children[cell];
const interactiveChildren = getFocusableElements(focusedCellElement);
if (interactiveChildren?.length > 0 && interactiveChildren[0]) {
// currently a cell can have only one interact-able element in it, which gets auto-focused.
interactiveChildren[0].focus();
} else {
// cell gets focus if there is no interact-able elements in it.
focusedCellElement.focus();
const focusedCellElement = listRef.current?.children[row + 1]?.children[cell];
if (focusedCellElement) {
const interactiveChildren = getFocusableElements(focusedCellElement);
if (interactiveChildren?.length > 0 && interactiveChildren[0]) {
// currently a cell can have only one interact-able element in it, which gets auto-focused.
interactiveChildren[0].focus();
} else {
// cell gets focus if there is no interact-able elements in it.
focusedCellElement.focus();
}
}
};

Expand Down
Loading