Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/FlatList/index.ios.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>({ref, ...props}: CustomFlatListProps<T>) {
const {maintainVisibleContentPosition: originalMaintainVisibleContentPosition, ...rest} = props;
const {maintainVisibleContentPosition: originalMaintainVisibleContentPosition, shouldDisableVisibleContentPosition, ...rest} = props;
const [isScrolling, setIsScrolling] = useState(false);

const handleScrollBegin = useCallback(() => {
Expand All @@ -15,7 +15,7 @@ function CustomFlatList<T>({ref, ...props}: CustomFlatListProps<T>) {
setIsScrolling(false);
}, []);

const maintainVisibleContentPosition = isScrolling ? undefined : originalMaintainVisibleContentPosition;
const maintainVisibleContentPosition = isScrolling || shouldDisableVisibleContentPosition ? undefined : originalMaintainVisibleContentPosition;

return (
<FlatList<T>
Expand Down
1 change: 1 addition & 0 deletions src/components/FlatList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function getScrollableNode(flatList: FlatList | null): HTMLElement | undefined {

type CustomFlatListProps<T> = FlatListProps<T> & {
ref?: ForwardedRef<FlatList>;
shouldDisableVisibleContentPosition?: boolean;
};

function MVCPFlatList<TItem>({maintainVisibleContentPosition, horizontal = false, onScroll, ref, ...props}: CustomFlatListProps<TItem>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type BaseInvertedFlatListProps<T> = Omit<FlatListProps<T>, 'data' | 'renderItem'
renderItem: ListRenderItem<T>;
initialScrollKey?: string | null;
ref?: ForwardedRef<RNFlatList>;
shouldDisableVisibleContentPosition?: boolean;
};

const AUTOSCROLL_TO_TOP_THRESHOLD = 250;
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/report/ReportActionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ function ReportActionsList({
shouldScrollToEndAfterLayout ? styles.opacity0 : styles.opacity1,
shouldFocusToTopOnMount ? styles.justifyContentEnd : undefined,
]}
shouldDisableVisibleContentPosition={shouldScrollToEndAfterLayout}
keyExtractor={keyExtractor}
initialNumToRender={initialNumToRender}
onEndReached={onEndReached}
Expand Down
Loading