Guard against null refs in findSiblingElement (#7228)

pull/21833/head
Michael Telatynski 2021-11-30 09:26:38 +00:00 committed by GitHub
parent 1d2965a111
commit 766d1ee3e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -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];
}
}