From f6131930ca443f61ba2dfd2a42447e00c36b3eb0 Mon Sep 17 00:00:00 2001 From: Tsaqif Date: Fri, 21 Jun 2024 14:10:12 +0700 Subject: [PATCH] Fix report doesn't scroll down when receiving new message Signed-off-by: Tsaqif --- src/components/FlatList/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/FlatList/index.tsx b/src/components/FlatList/index.tsx index 9f42e9597c79..f54eddcbeb79 100644 --- a/src/components/FlatList/index.tsx +++ b/src/components/FlatList/index.tsx @@ -44,6 +44,8 @@ function MVCPFlatList({maintainVisibleContentPosition, horizontal = false const mutationObserverRef = useRef(null); const lastScrollOffsetRef = useRef(0); const isListRenderedRef = useRef(false); + const mvcpAutoscrollToTopThresholdRef = useRef(mvcpAutoscrollToTopThreshold); + mvcpAutoscrollToTopThresholdRef.current = mvcpAutoscrollToTopThreshold; const getScrollOffset = useCallback((): number => { if (!scrollRef.current) { @@ -105,11 +107,11 @@ function MVCPFlatList({maintainVisibleContentPosition, horizontal = false const scrollOffset = getScrollOffset(); prevFirstVisibleOffsetRef.current = firstVisibleViewOffset; scrollToOffset(scrollOffset + delta, false); - if (mvcpAutoscrollToTopThreshold != null && scrollOffset <= mvcpAutoscrollToTopThreshold) { + if (mvcpAutoscrollToTopThresholdRef.current != null && scrollOffset <= mvcpAutoscrollToTopThresholdRef.current) { scrollToOffset(0, true); } } - }, [getScrollOffset, scrollToOffset, mvcpMinIndexForVisible, mvcpAutoscrollToTopThreshold, horizontal]); + }, [getScrollOffset, scrollToOffset, mvcpMinIndexForVisible, horizontal]); const setupMutationObserver = useCallback(() => { const contentView = getContentView();