Skip to content

Commit 430a837

Browse files
authored
Merge pull request #24369 from tienifr/fix/23886-composer-out-focus-when-the-thread-has-many-messages
2 parents ae90744 + f74dbb1 commit 430a837

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/pages/home/report/ReportActionItem.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import * as PersonalDetailsUtils from '../../../libs/PersonalDetailsUtils';
6464
import ReportActionItemBasicMessage from './ReportActionItemBasicMessage';
6565
import * as store from '../../../libs/actions/ReimbursementAccount/store';
6666
import * as BankAccounts from '../../../libs/actions/BankAccounts';
67+
import usePrevious from '../../../hooks/usePrevious';
6768
import ReportScreenContext from '../ReportScreenContext';
6869
import Permissions from '../../../libs/Permissions';
6970

@@ -131,6 +132,7 @@ function ReportActionItem(props) {
131132
const textInputRef = useRef();
132133
const popoverAnchorRef = useRef();
133134
const downloadedPreviews = useRef([]);
135+
const prevDraftMessage = usePrevious(props.draftMessage);
134136
const originalReportID = ReportUtils.getOriginalReportID(props.report.reportID, props.action);
135137
const originalReport = props.report.reportID === originalReportID ? props.report : ReportUtils.getReport(originalReportID);
136138

@@ -152,14 +154,13 @@ function ReportActionItem(props) {
152154
[props.action.reportActionID, reactionListRef],
153155
);
154156

155-
const isDraftEmpty = !props.draftMessage;
156157
useEffect(() => {
157-
if (isDraftEmpty) {
158+
if (prevDraftMessage || !props.draftMessage) {
158159
return;
159160
}
160161

161162
focusTextInputAfterAnimation(textInputRef.current, 100);
162-
}, [isDraftEmpty]);
163+
}, [prevDraftMessage, props.draftMessage]);
163164

164165
useEffect(() => {
165166
if (!Permissions.canUseLinkPreviews()) {

0 commit comments

Comments
 (0)