From 657b79ebb192b5ca2d099f7bbe0d93d14d444bf3 Mon Sep 17 00:00:00 2001 From: Tsaqif Date: Mon, 6 Nov 2023 22:58:41 +0700 Subject: [PATCH] Move the code into mount of ReportActionMessageEdit Signed-off-by: Tsaqif --- src/pages/home/report/ReportActionItem.js | 3 --- src/pages/home/report/ReportActionItemMessageEdit.js | 10 +++++++++- src/pages/home/report/ReportActionsList.js | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index e44eeacab752..4da88fd5d352 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -194,9 +194,6 @@ function ReportActionItem(props) { return; } - if (textInputRef.current) { - textInputRef.current.focus(); - } focusTextInputAfterAnimation(textInputRef.current, 100); }, [prevDraftMessage, props.draftMessage]); diff --git a/src/pages/home/report/ReportActionItemMessageEdit.js b/src/pages/home/report/ReportActionItemMessageEdit.js index d4162f886837..696940c9cf94 100644 --- a/src/pages/home/report/ReportActionItemMessageEdit.js +++ b/src/pages/home/report/ReportActionItemMessageEdit.js @@ -169,6 +169,15 @@ function ReportActionItemMessageEdit(props) { [props.action.reportActionID], ); + // Scroll content of textInputRef to bottom + useEffect(() => { + if (!textInputRef.current) { + return; + } + textInputRef.current.focus(); + textInputRef.current.scrollTop = textInputRef.current.scrollHeight; + }, []); + useEffect(() => { // For mobile Safari, updating the selection prop on an unfocused input will cause it to automatically gain focus // and subsequent programmatic focus shifts (e.g., modal focus trap) to show the blue frame (:focus-visible style), @@ -181,7 +190,6 @@ function ReportActionItemMessageEdit(props) { }); return prevDraft; }); - textInputRef.current.scrollTop = textInputRef.current.scrollHeight; } return () => { diff --git a/src/pages/home/report/ReportActionsList.js b/src/pages/home/report/ReportActionsList.js index 4fd2bd21c99e..11c8077745f9 100644 --- a/src/pages/home/report/ReportActionsList.js +++ b/src/pages/home/report/ReportActionsList.js @@ -429,6 +429,7 @@ function ReportActionsList({ keyboardShouldPersistTaps="handled" onLayout={onLayoutInner} onScroll={trackVerticalScrolling} + onScrollToIndexFailed={() => {}} extraData={extraData} />