Skip to content

Commit a1f6240

Browse files
committed
fix: 30495
1 parent a59d56f commit a1f6240

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/hooks/useReportScrollManager/index.native.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import {useContext, useCallback} from 'react';
22
import {ActionListContext} from '../../pages/home/ReportScreenContext';
33
import ReportScrollManagerData from './types';
44

5+
let isAutomaticScrollToBottom = false;
6+
57
function useReportScrollManager(): ReportScrollManagerData {
68
const flatListRef = useContext(ActionListContext);
79

@@ -24,10 +26,11 @@ function useReportScrollManager(): ReportScrollManagerData {
2426
return;
2527
}
2628

29+
isAutomaticScrollToBottom = true;
2730
flatListRef.current.scrollToOffset({animated: false, offset: 0});
2831
}, [flatListRef]);
2932

30-
return {ref: flatListRef, scrollToIndex, scrollToBottom};
33+
return {ref: flatListRef, scrollToIndex, scrollToBottom, isAutomaticScrollToBottom};
3134
}
3235

3336
export default useReportScrollManager;

src/pages/home/report/ReportActionsView.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import PopoverReactionList from './ReactionList/PopoverReactionList';
2121
import getIsReportFullyVisible from '../../../libs/getIsReportFullyVisible';
2222
import {ReactionListContext} from '../ReportScreenContext';
2323
import useInitialValue from '../../../hooks/useInitialValue';
24+
import useReportScrollManager from '../../../hooks/useReportScrollManager';
2425

2526
const propTypes = {
2627
/** The report currently being looked at */
@@ -80,6 +81,7 @@ function ReportActionsView(props) {
8081

8182
const isFocused = useIsFocused();
8283
const reportID = props.report.reportID;
84+
const reportScrollManager = useReportScrollManager();
8385

8486
/**
8587
* @returns {Boolean}
@@ -169,8 +171,13 @@ function ReportActionsView(props) {
169171
* displaying.
170172
*/
171173
const loadNewerChats = useMemo(
172-
() =>
173-
_.throttle(({distanceFromStart}) => {
174+
() => {
175+
return _.throttle(({distanceFromStart}) => {
176+
if (reportScrollManager.isAutomaticScrollToBottom) {
177+
reportScrollManager.isAutomaticScrollToBottom = false;
178+
return;
179+
}
180+
174181
if (props.isLoadingNewerReportActions || props.isLoadingInitialReportActions) {
175182
return;
176183
}
@@ -192,8 +199,9 @@ function ReportActionsView(props) {
192199

193200
const newestReportAction = _.first(props.reportActions);
194201
Report.getNewerActions(reportID, newestReportAction.reportActionID);
195-
}, 500),
196-
[props.isLoadingNewerReportActions, props.isLoadingInitialReportActions, props.reportActions, reportID],
202+
}, 500)
203+
},
204+
[props.isLoadingNewerReportActions, props.isLoadingInitialReportActions, props.reportActions, reportID, reportScrollManager],
197205
);
198206

199207
/**

0 commit comments

Comments
 (0)