diff --git a/src/components/ui/InfiniteScroll.tsx b/src/components/ui/InfiniteScroll.tsx index 01f4ca4da..2cd357a25 100644 --- a/src/components/ui/InfiniteScroll.tsx +++ b/src/components/ui/InfiniteScroll.tsx @@ -92,10 +92,6 @@ const InfiniteScroll: FC = ({ state.listItemElements = container.querySelectorAll(itemSelector); - if (noScrollRestore) { - return; - } - let newScrollTop; if (state.currentAnchor && Array.from(state.listItemElements).includes(state.currentAnchor)) { @@ -104,12 +100,16 @@ const InfiniteScroll: FC = ({ newScrollTop = scrollTop + (newAnchorTop - state.currentAnchorTop); } else { const nextAnchor = state.listItemElements[0]; - if (nextAnchor && nextAnchor.offsetParent) { + if (nextAnchor) { state.currentAnchor = nextAnchor; state.currentAnchorTop = nextAnchor.getBoundingClientRect().top; } } + if (noScrollRestore) { + return; + } + resetScroll(container, newScrollTop); state.isScrollTopJustUpdated = true;