From a49b02e291c91ab32481a9c9d1344fc58e0b9214 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Fri, 30 Apr 2021 01:31:50 +0300 Subject: [PATCH] Infinite Scroll: Attempt to fix a weird bug with missing chats --- src/components/ui/InfiniteScroll.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/ui/InfiniteScroll.tsx b/src/components/ui/InfiniteScroll.tsx index d1cf6d00..fe2cff7d 100644 --- a/src/components/ui/InfiniteScroll.tsx +++ b/src/components/ui/InfiniteScroll.tsx @@ -140,7 +140,7 @@ const InfiniteScroll: FC = ({ const nextAnchor = listItemElements[0]; if (nextAnchor) { const nextAnchorTop = nextAnchor.getBoundingClientRect().top; - const newAnchorTop = currentAnchor && currentAnchor !== nextAnchor + const newAnchorTop = currentAnchor && currentAnchor.offsetParent && currentAnchor !== nextAnchor ? currentAnchor.getBoundingClientRect().top : nextAnchorTop; const isMovingUp = ( @@ -161,7 +161,7 @@ const InfiniteScroll: FC = ({ const nextAnchor = listItemElements[listLength - 1]; if (nextAnchor) { const nextAnchorTop = nextAnchor.getBoundingClientRect().top; - const newAnchorTop = currentAnchor && currentAnchor !== nextAnchor + const newAnchorTop = currentAnchor && currentAnchor.offsetParent && currentAnchor !== nextAnchor ? currentAnchor.getBoundingClientRect().top : nextAnchorTop; const isMovingDown = ( @@ -179,7 +179,7 @@ const InfiniteScroll: FC = ({ } if (!isUpdated) { - if (currentAnchor) { + if (currentAnchor && currentAnchor.offsetParent) { stateRef.current.currentAnchorTop = currentAnchor.getBoundingClientRect().top; } else { const nextAnchor = listItemElements[0];