From 526d8a1d830d30e8c5bc2a7f1daab640d53dad4e Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 2 Jun 2022 21:22:40 -0500 Subject: [PATCH] ScrollableList: track the second item instead of the top one --- app/soapbox/components/scrollable_list.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/soapbox/components/scrollable_list.tsx b/app/soapbox/components/scrollable_list.tsx index caad06dfe7..e546f2a454 100644 --- a/app/soapbox/components/scrollable_list.tsx +++ b/app/soapbox/components/scrollable_list.tsx @@ -170,7 +170,9 @@ const ScrollableList = React.forwardRef(({ }; const handleRangeChange = (range: ListRange) => { - topIndex.current = range.startIndex; + // HACK: using the first index can be buggy. + // Track the second item instead, unless the endIndex comes before it (eg one 1 item in view). + topIndex.current = Math.min(range.startIndex + 1, range.endIndex); handleScroll(); };