Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent autoscroll to bottom on android when last track expense whisper is unresolved #43085

Merged
merged 2 commits into from
Jun 7, 2024
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
17 changes: 10 additions & 7 deletions src/hooks/useReportScrollManager/index.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ function useReportScrollManager(): ReportScrollManagerData {
/**
* Scroll to the provided index.
*/
const scrollToIndex = (index: number) => {
if (!flatListRef?.current) {
return;
}

flatListRef.current.scrollToIndex({index});
};
const scrollToIndex = useCallback(
(index: number) => {
if (!flatListRef?.current) {
return;
}

flatListRef.current.scrollToIndex({index});
},
[flatListRef],
);

/**
* Scroll to the bottom of the flatlist.
Expand Down
15 changes: 9 additions & 6 deletions src/hooks/useReportScrollManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ function useReportScrollManager(): ReportScrollManagerData {
/**
* Scroll to the provided index. On non-native implementations we do not want to scroll when we are scrolling because
*/
const scrollToIndex = (index: number, isEditing?: boolean) => {
if (!flatListRef?.current || isEditing) {
return;
}
const scrollToIndex = useCallback(
(index: number, isEditing?: boolean) => {
if (!flatListRef?.current || isEditing) {
return;
}

flatListRef.current.scrollToIndex({index, animated: true});
};
flatListRef.current.scrollToIndex({index, animated: true});
},
[flatListRef],
);

/**
* Scroll to the bottom of the flatlist.
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ function ReportActionItem({
return;
}

if (prevActionResolution !== (action.originalMessage.resolution ?? null)) {
if (prevActionResolution !== action.originalMessage.resolution) {
reportScrollManager.scrollToIndex(index);
}
}, [index, action, prevActionResolution, reportScrollManager, isActionableWhisper]);
Expand Down
Loading