From 00039cb21b917fe9ffc636d2a8e9f14b79d49178 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Tue, 6 Dec 2022 18:35:13 +0200 Subject: [PATCH] center highlighted post in permalink view (#6836) --- app/components/post_list/post_list.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/components/post_list/post_list.tsx b/app/components/post_list/post_list.tsx index a3bafa2911..e62d3daab4 100644 --- a/app/components/post_list/post_list.tsx +++ b/app/components/post_list/post_list.tsx @@ -348,8 +348,13 @@ const PostList = ({ scrolledToHighlighted.current = true; // eslint-disable-next-line max-nested-callbacks const index = orderedPosts.findIndex((p) => typeof p !== 'string' && p.id === highlightedId); - if (index >= 0) { - scrollToIndex(index, true); + if (index >= 0 && listRef.current) { + listRef.current?.scrollToIndex({ + animated: true, + index, + viewOffset: 0, + viewPosition: 0.5, // 0 is at bottom + }); } } }, 500);