From 766d1ee3e86ac9a67d8558bbfeecb2be55901ed5 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 30 Nov 2021 09:26:38 +0000 Subject: [PATCH] Guard against null refs in findSiblingElement (#7228) --- src/accessibility/RovingTabIndex.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/accessibility/RovingTabIndex.tsx b/src/accessibility/RovingTabIndex.tsx index 51cc2322d1..a7f8f735ce 100644 --- a/src/accessibility/RovingTabIndex.tsx +++ b/src/accessibility/RovingTabIndex.tsx @@ -165,13 +165,13 @@ export const findSiblingElement = ( ): RefObject => { 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]; } }