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

Commit

Permalink
Guard against null refs in findSiblingElement (#7228)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Nov 30, 2021
1 parent 1d2965a commit 766d1ee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/accessibility/RovingTabIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ export const findSiblingElement = (
): RefObject<HTMLElement> => {
if (backwards) {
for (let i = startIndex; i < refs.length && i >= 0; i--) {
if (refs[i].current.offsetParent !== null) {
if (refs[i].current?.offsetParent !== null) {
return refs[i];
}
}
} else {
for (let i = startIndex; i < refs.length && i >= 0; i++) {
if (refs[i].current.offsetParent !== null) {
if (refs[i].current?.offsetParent !== null) {
return refs[i];
}
}
Expand Down

0 comments on commit 766d1ee

Please sign in to comment.