diff --git a/patches/react-native+0.73.4+024+fixMVCPAndroid.patch b/patches/react-native+0.73.4+024+fixMVCPAndroid.patch new file mode 100644 index 000000000000..fe37e38c3040 --- /dev/null +++ b/patches/react-native+0.73.4+024+fixMVCPAndroid.patch @@ -0,0 +1,334 @@ +diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/MaintainVisibleScrollPositionHelper.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/MaintainVisibleScrollPositionHelper.java +index fff761f..2cebd6b 100644 +--- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/MaintainVisibleScrollPositionHelper.java ++++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/MaintainVisibleScrollPositionHelper.java +@@ -82,6 +82,7 @@ public class MaintainVisibleScrollPositionHelper currentScroll || i == contentView.getChildCount() - 1) { +- mFirstVisibleView = new WeakReference<>(child); +- Rect frame = new Rect(); +- child.getHitRect(frame); +- mPrevFirstVisibleFrame = frame; +- break; ++ if ((position > currentScroll && position < firstVisibleViewPosition) || ++ (firstVisibleView == null && i == contentView.getChildCount() - 1)) { ++ firstVisibleView = child; ++ firstVisibleViewPosition = position; ++ } ++ } ++ mFirstVisibleView = new WeakReference<>(firstVisibleView); ++ } ++ ++ private View getFirstVisibleView() { ++ return mFirstVisibleView != null ? mFirstVisibleView.get() : null; ++ } ++ ++ private void willMountItemsInternal() { ++ View firstVisibleView = getFirstVisibleView(); ++ ++ // If we don't have a first visible view because no scroll happened call onScroll ++ // to update it. ++ if (firstVisibleView == null) { ++ onScroll(); ++ firstVisibleView = getFirstVisibleView(); ++ ++ // There are cases where it is possible for this to still be null so just bail out. ++ if (firstVisibleView == null) { ++ return; + } + } ++ Rect frame = new Rect(); ++ firstVisibleView.getHitRect(frame); ++ mPrevFirstVisibleFrame = frame; + } + + // UIManagerListener +@@ -177,19 +205,19 @@ public class MaintainVisibleScrollPositionHelper(props: FlatListProps, ref: ForwardedRef) { - const {scrollPosition, setScrollPosition} = useContext(ActionListContext); + const lastScrollOffsetRef = useRef(0); const onScreenFocus = useCallback(() => { if (typeof ref === 'function') { return; } - if (!ref?.current || !scrollPosition?.offset) { + if (!ref?.current || !lastScrollOffsetRef.current) { return; } - if (ref.current && scrollPosition.offset) { - ref.current.scrollToOffset({offset: scrollPosition.offset, animated: false}); + if (ref.current && lastScrollOffsetRef.current) { + ref.current.scrollToOffset({offset: lastScrollOffsetRef.current, animated: false}); } - }, [scrollPosition?.offset, ref]); + }, [ref]); // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps - const onMomentumScrollEnd = useCallback((event: NativeSyntheticEvent) => setScrollPosition({offset: event.nativeEvent.contentOffset.y}), []); + const onMomentumScrollEnd = useCallback((event: NativeSyntheticEvent) => { + lastScrollOffsetRef.current = event.nativeEvent.contentOffset.y; + }, []); useFocusEffect( useCallback(() => { diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index a3ae69be722e..c608a3105675 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -486,6 +486,7 @@ function ReportActionsView({ if (!reportActions.length) { return null; } + // AutoScroll is disabled when we do linking to a specific reportAction const shouldEnableAutoScroll = hasNewestReportAction && (!reportActionID || !isNavigatingToLinkedMessage); return (