From 57cb73a0280789cf24fa4df3a4536b97beca7ed3 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 30 Nov 2021 09:19:45 +0000 Subject: [PATCH] Guard against null refs in findSiblingElement --- 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 8c49a4d6ae7..95153512ddf 100644 --- a/src/accessibility/RovingTabIndex.tsx +++ b/src/accessibility/RovingTabIndex.tsx @@ -160,13 +160,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]; } }