@@ -69,6 +69,7 @@ const emojiButtonID = 'emojiButton';
69
69
const messageEditInput = 'messageEditInput' ;
70
70
71
71
const isMobileSafari = Browser . isMobileSafari ( ) ;
72
+ const shouldUseForcedSelectionRange = shouldUseEmojiPickerSelection ( ) ;
72
73
73
74
function ReportActionItemMessageEdit (
74
75
{ action, draftMessage, reportID, index, shouldDisableEmojiPicker = false , preferredSkinTone = CONST . EMOJI_DEFAULT_SKIN_TONE } : ReportActionItemMessageEditProps ,
@@ -330,7 +331,6 @@ function ReportActionItemMessageEdit(
330
331
deleteDraft ( ) ;
331
332
} , [ action , debouncedSaveDraft , deleteDraft , draft , reportID ] ) ;
332
333
333
- const shouldUseEmojiPickerSelectionRef = shouldUseEmojiPickerSelection ( ) ;
334
334
/**
335
335
* @param emoji
336
336
*/
@@ -341,9 +341,9 @@ function ReportActionItemMessageEdit(
341
341
} ;
342
342
setSelection ( newSelection ) ;
343
343
344
- if ( shouldUseEmojiPickerSelectionRef ) {
345
- // immediately set the selection again on android and Chrome mobile after focusing the
346
- // input which seems to change the cursor position for a brief moment
344
+ if ( shouldUseForcedSelectionRange ) {
345
+ // On Android and Chrome mobile, focusing the input sets the cursor position back to the start.
346
+ // To fix this, immediately set the selection again after focusing the input.
347
347
emojiPickerSelectionRef . current = newSelection ;
348
348
}
349
349
updateDraft ( ComposerUtils . insertText ( draft , selection , `${ emoji } ` ) ) ;
@@ -460,10 +460,7 @@ function ReportActionItemMessageEdit(
460
460
< EmojiPickerButton
461
461
isDisabled = { shouldDisableEmojiPicker }
462
462
onModalHide = { ( ) => {
463
- const emojiPickerSelection = emojiPickerSelectionRef . current ? { ...emojiPickerSelectionRef . current } : undefined ;
464
- emojiPickerSelectionRef . current = undefined ;
465
-
466
- focus ( true , emojiPickerSelection ) ;
463
+ focus ( true , emojiPickerSelectionRef . current ? { ...emojiPickerSelectionRef . current } : undefined ) ;
467
464
} }
468
465
onEmojiSelected = { addEmojiToTextBox }
469
466
id = { emojiButtonID }
0 commit comments