Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 23886 Composer out focus when the thread has many messages #24369

7 changes: 4 additions & 3 deletions src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import * as PersonalDetailsUtils from '../../../libs/PersonalDetailsUtils';
import ReportActionItemBasicMessage from './ReportActionItemBasicMessage';
import * as store from '../../../libs/actions/ReimbursementAccount/store';
import * as BankAccounts from '../../../libs/actions/BankAccounts';
import usePrevious from '../../../hooks/usePrevious';
import ReportScreenContext from '../ReportScreenContext';
import Permissions from '../../../libs/Permissions';

Expand Down Expand Up @@ -131,6 +132,7 @@ function ReportActionItem(props) {
const textInputRef = useRef();
const popoverAnchorRef = useRef();
const downloadedPreviews = useRef([]);
const prevDraftMessage = usePrevious(props.draftMessage);
const originalReportID = ReportUtils.getOriginalReportID(props.report.reportID, props.action);
const originalReport = props.report.reportID === originalReportID ? props.report : ReportUtils.getReport(originalReportID);

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

const isDraftEmpty = !props.draftMessage;
useEffect(() => {
if (isDraftEmpty) {
if (prevDraftMessage || !props.draftMessage) {
return;
}

focusTextInputAfterAnimation(textInputRef.current, 100);
}, [isDraftEmpty]);
}, [prevDraftMessage, props.draftMessage]);

useEffect(() => {
if (!Permissions.canUseLinkPreviews()) {
Expand Down