From 4628a5b82f8f1056844587536e2dd70c466f073c Mon Sep 17 00:00:00 2001 From: Anas Up Date: Fri, 22 Nov 2024 06:12:48 -0500 Subject: [PATCH] wrap scrollToBottomForCurrentUserAction with InteractionManager.runAfterInteractions --- src/pages/home/report/ReportActionsList.tsx | 24 +++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index 57d3c48e3b61..cf0536ca07b5 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -421,19 +421,21 @@ function ReportActionsList({ const scrollToBottomForCurrentUserAction = useCallback( (isFromCurrentUser: boolean) => { - // If a new comment is added and it's from the current user scroll to the bottom otherwise leave the user positioned where - // they are now in the list. - if (!isFromCurrentUser) { - return; - } - if (!hasNewestReportActionRef.current) { - if (isInNarrowPaneModal) { + InteractionManager.runAfterInteractions(() => { + // If a new comment is added and it's from the current user scroll to the bottom otherwise leave the user positioned where + // they are now in the list. + if (!isFromCurrentUser) { return; } - Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.reportID)); - return; - } - InteractionManager.runAfterInteractions(() => reportScrollManager.scrollToBottom()); + if (!hasNewestReportActionRef.current) { + if (isInNarrowPaneModal) { + return; + } + Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.reportID)); + return; + } + reportScrollManager.scrollToBottom(); + }); }, [isInNarrowPaneModal, reportScrollManager, report.reportID], );