From 3ee11aa236c30c60b2521de000f542623af0ff41 Mon Sep 17 00:00:00 2001 From: VickyStash Date: Fri, 3 Oct 2025 10:15:48 +0200 Subject: [PATCH] Fix expense opens at bottom and only moves up when scrolled on ios --- src/components/FlatList/index.ios.tsx | 4 ++-- src/components/FlatList/index.tsx | 1 + .../InvertedFlatList/BaseInvertedFlatList/index.tsx | 1 + src/pages/home/report/ReportActionsList.tsx | 1 + 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/FlatList/index.ios.tsx b/src/components/FlatList/index.ios.tsx index 4c73b4417d18..242baeb6be5b 100644 --- a/src/components/FlatList/index.ios.tsx +++ b/src/components/FlatList/index.ios.tsx @@ -4,7 +4,7 @@ import type {CustomFlatListProps} from './index'; // On iOS, we have to unset maintainVisibleContentPosition while the user is scrolling to prevent jumping to the beginning issue function CustomFlatList({ref, ...props}: CustomFlatListProps) { - const {maintainVisibleContentPosition: originalMaintainVisibleContentPosition, ...rest} = props; + const {maintainVisibleContentPosition: originalMaintainVisibleContentPosition, shouldDisableVisibleContentPosition, ...rest} = props; const [isScrolling, setIsScrolling] = useState(false); const handleScrollBegin = useCallback(() => { @@ -15,7 +15,7 @@ function CustomFlatList({ref, ...props}: CustomFlatListProps) { setIsScrolling(false); }, []); - const maintainVisibleContentPosition = isScrolling ? undefined : originalMaintainVisibleContentPosition; + const maintainVisibleContentPosition = isScrolling || shouldDisableVisibleContentPosition ? undefined : originalMaintainVisibleContentPosition; return ( diff --git a/src/components/FlatList/index.tsx b/src/components/FlatList/index.tsx index e7109019a9d4..a1969e987444 100644 --- a/src/components/FlatList/index.tsx +++ b/src/components/FlatList/index.tsx @@ -43,6 +43,7 @@ function getScrollableNode(flatList: FlatList | null): HTMLElement | undefined { type CustomFlatListProps = FlatListProps & { ref?: ForwardedRef; + shouldDisableVisibleContentPosition?: boolean; }; function MVCPFlatList({maintainVisibleContentPosition, horizontal = false, onScroll, ref, ...props}: CustomFlatListProps) { diff --git a/src/components/InvertedFlatList/BaseInvertedFlatList/index.tsx b/src/components/InvertedFlatList/BaseInvertedFlatList/index.tsx index 47274b133c6f..788ba301249e 100644 --- a/src/components/InvertedFlatList/BaseInvertedFlatList/index.tsx +++ b/src/components/InvertedFlatList/BaseInvertedFlatList/index.tsx @@ -25,6 +25,7 @@ type BaseInvertedFlatListProps = Omit, 'data' | 'renderItem' renderItem: ListRenderItem; initialScrollKey?: string | null; ref?: ForwardedRef; + shouldDisableVisibleContentPosition?: boolean; }; const AUTOSCROLL_TO_TOP_THRESHOLD = 250; diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index e466d1b2030e..daca322250e4 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -817,6 +817,7 @@ function ReportActionsList({ shouldScrollToEndAfterLayout ? styles.opacity0 : styles.opacity1, shouldFocusToTopOnMount ? styles.justifyContentEnd : undefined, ]} + shouldDisableVisibleContentPosition={shouldScrollToEndAfterLayout} keyExtractor={keyExtractor} initialNumToRender={initialNumToRender} onEndReached={onEndReached}