@@ -64,6 +64,7 @@ import * as PersonalDetailsUtils from '../../../libs/PersonalDetailsUtils';
64
64
import ReportActionItemBasicMessage from './ReportActionItemBasicMessage' ;
65
65
import * as store from '../../../libs/actions/ReimbursementAccount/store' ;
66
66
import * as BankAccounts from '../../../libs/actions/BankAccounts' ;
67
+ import usePrevious from '../../../hooks/usePrevious' ;
67
68
import ReportScreenContext from '../ReportScreenContext' ;
68
69
import Permissions from '../../../libs/Permissions' ;
69
70
@@ -131,6 +132,7 @@ function ReportActionItem(props) {
131
132
const textInputRef = useRef ( ) ;
132
133
const popoverAnchorRef = useRef ( ) ;
133
134
const downloadedPreviews = useRef ( [ ] ) ;
135
+ const prevDraftMessage = usePrevious ( props . draftMessage ) ;
134
136
const originalReportID = ReportUtils . getOriginalReportID ( props . report . reportID , props . action ) ;
135
137
const originalReport = props . report . reportID === originalReportID ? props . report : ReportUtils . getReport ( originalReportID ) ;
136
138
@@ -152,14 +154,13 @@ function ReportActionItem(props) {
152
154
[ props . action . reportActionID , reactionListRef ] ,
153
155
) ;
154
156
155
- const isDraftEmpty = ! props . draftMessage ;
156
157
useEffect ( ( ) => {
157
- if ( isDraftEmpty ) {
158
+ if ( prevDraftMessage || ! props . draftMessage ) {
158
159
return ;
159
160
}
160
161
161
162
focusTextInputAfterAnimation ( textInputRef . current , 100 ) ;
162
- } , [ isDraftEmpty ] ) ;
163
+ } , [ prevDraftMessage , props . draftMessage ] ) ;
163
164
164
165
useEffect ( ( ) => {
165
166
if ( ! Permissions . canUseLinkPreviews ( ) ) {
0 commit comments