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

Commit 766d1ee

Browse files
authored
Guard against null refs in findSiblingElement (#7228)
1 parent 1d2965a commit 766d1ee

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/accessibility/RovingTabIndex.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,13 @@ export const findSiblingElement = (
165165
): RefObject<HTMLElement> => {
166166
if (backwards) {
167167
for (let i = startIndex; i < refs.length && i >= 0; i--) {
168-
if (refs[i].current.offsetParent !== null) {
168+
if (refs[i].current?.offsetParent !== null) {
169169
return refs[i];
170170
}
171171
}
172172
} else {
173173
for (let i = startIndex; i < refs.length && i >= 0; i++) {
174-
if (refs[i].current.offsetParent !== null) {
174+
if (refs[i].current?.offsetParent !== null) {
175175
return refs[i];
176176
}
177177
}

0 commit comments

Comments
 (0)