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

fix: 30726 A blank spot appears after deleting a money request #31670

Merged
merged 17 commits into from
Dec 27, 2023
14 changes: 14 additions & 0 deletions src/pages/home/report/ReportActionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ function ReportActionsList({
const lastVisibleActionCreatedRef = useRef(report.lastVisibleActionCreated);
const lastReadTimeRef = useRef(report.lastReadTime);

const sortedVisibleReportActions = _.filter(sortedReportActions, (s) => isOffline || s.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || s.errors);
const lastActionIndex = lodashGet(sortedVisibleReportActions, [0, 'reportActionID']);
const reportActionSize = useRef(sortedVisibleReportActions.length);

const previousLastIndex = useRef(lastActionIndex);

const linkedReportActionID = lodashGet(route, 'params.reportActionID', '');

// This state is used to force a re-render when the user manually marks a message as unread
Expand All @@ -173,6 +179,14 @@ function ReportActionsList({
opacity.value = withTiming(1, {duration: 100});
}, [opacity]);

useEffect(() => {
if (previousLastIndex.current !== lastActionIndex && reportActionSize.current > sortedVisibleReportActions.length) {
reportScrollManager.scrollToBottom();
}
previousLastIndex.current = lastActionIndex;
reportActionSize.current = sortedVisibleReportActions.length;
}, [lastActionIndex, sortedVisibleReportActions.length, reportScrollManager]);

useEffect(() => {
// If the reportID changes, we reset the userActiveSince to null, we need to do it because
// the parent component is sending the previous reportID even when the user isn't active
Expand Down
Loading