Skip to content

Commit

Permalink
Move the code into mount of ReportActionMessageEdit
Browse files Browse the repository at this point in the history
Signed-off-by: Tsaqif <[email protected]>
  • Loading branch information
tsa321 committed Nov 6, 2023
1 parent 9402276 commit 657b79e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 0 additions & 3 deletions src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,6 @@ function ReportActionItem(props) {
return;
}

if (textInputRef.current) {
textInputRef.current.focus();
}
focusTextInputAfterAnimation(textInputRef.current, 100);
}, [prevDraftMessage, props.draftMessage]);

Expand Down
10 changes: 9 additions & 1 deletion src/pages/home/report/ReportActionItemMessageEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -181,7 +190,6 @@ function ReportActionItemMessageEdit(props) {
});
return prevDraft;
});
textInputRef.current.scrollTop = textInputRef.current.scrollHeight;
}

return () => {
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/report/ReportActionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ function ReportActionsList({
keyboardShouldPersistTaps="handled"
onLayout={onLayoutInner}
onScroll={trackVerticalScrolling}
onScrollToIndexFailed={() => {}}
extraData={extraData}
/>
</Animated.View>
Expand Down

0 comments on commit 657b79e

Please sign in to comment.