From 9207930f2c9794de631a390f369d31d74aa28448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sat, 31 Aug 2024 16:04:35 +0200 Subject: [PATCH] pl-fe: fix initial scroll MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- packages/pl-fe/src/components/scrollable-list.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/pl-fe/src/components/scrollable-list.tsx b/packages/pl-fe/src/components/scrollable-list.tsx index c368ad47d..1c7cf6d23 100644 --- a/packages/pl-fe/src/components/scrollable-list.tsx +++ b/packages/pl-fe/src/components/scrollable-list.tsx @@ -212,13 +212,16 @@ const ScrollableList = React.forwardRef(({ /** Figure out the initial index to scroll to. */ const initialIndex = useMemo(() => { if (showLoading) return 0; - if (typeof initialTopMostItemIndex === 'number') { - return { - align: 'center', - index: initialTopMostItemIndex, - }; + + if (initialTopMostItemIndex) { + if (typeof initialTopMostItemIndex === 'number') { + return { + align: 'center', + index: initialTopMostItemIndex, + }; + } + return initialTopMostItemIndex; } - if (initialTopMostItemIndex) return initialTopMostItemIndex; if (scrollData && history.action === 'POP') { return {