Skip to content

Commit f613193

Browse files
committed
Fix report doesn't scroll down when receiving new message
Signed-off-by: Tsaqif <tsaiinkwa@yahoo.com>
1 parent 633e708 commit f613193

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/components/FlatList/index.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ function MVCPFlatList<TItem>({maintainVisibleContentPosition, horizontal = false
4444
const mutationObserverRef = useRef<MutationObserver | null>(null);
4545
const lastScrollOffsetRef = useRef(0);
4646
const isListRenderedRef = useRef(false);
47+
const mvcpAutoscrollToTopThresholdRef = useRef(mvcpAutoscrollToTopThreshold);
48+
mvcpAutoscrollToTopThresholdRef.current = mvcpAutoscrollToTopThreshold;
4749

4850
const getScrollOffset = useCallback((): number => {
4951
if (!scrollRef.current) {
@@ -105,11 +107,11 @@ function MVCPFlatList<TItem>({maintainVisibleContentPosition, horizontal = false
105107
const scrollOffset = getScrollOffset();
106108
prevFirstVisibleOffsetRef.current = firstVisibleViewOffset;
107109
scrollToOffset(scrollOffset + delta, false);
108-
if (mvcpAutoscrollToTopThreshold != null && scrollOffset <= mvcpAutoscrollToTopThreshold) {
110+
if (mvcpAutoscrollToTopThresholdRef.current != null && scrollOffset <= mvcpAutoscrollToTopThresholdRef.current) {
109111
scrollToOffset(0, true);
110112
}
111113
}
112-
}, [getScrollOffset, scrollToOffset, mvcpMinIndexForVisible, mvcpAutoscrollToTopThreshold, horizontal]);
114+
}, [getScrollOffset, scrollToOffset, mvcpMinIndexForVisible, horizontal]);
113115

114116
const setupMutationObserver = useCallback(() => {
115117
const contentView = getContentView();

0 commit comments

Comments
 (0)