From aff1934338f93bf57a7be28c2dae45b702b79930 Mon Sep 17 00:00:00 2001 From: daledah Date: Thu, 20 Mar 2025 19:54:45 +0700 Subject: [PATCH] fix: autoscroll on system whisper message --- src/pages/home/report/ReportActionsList.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index 6ceb6a296fec..d971beea3645 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -495,6 +495,22 @@ function ReportActionsList({ // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps }, [report.reportID]); + const previousLastAction = usePrevious(lastAction); + useEffect(() => { + if ( + lastAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_MENTION_WHISPER || + lastAction?.reportActionID === previousLastAction?.reportActionID || + !hasNewestReportAction || + scrollingVerticalOffset.current >= AUTOSCROLL_TO_TOP_THRESHOLD + ) { + return; + } + InteractionManager.runAfterInteractions(() => { + reportScrollManager.scrollToBottom(); + }); + // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps + }, [lastAction]); + /** * Show/hide the new floating message counter when user is scrolling back/forth in the history of messages. */