diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index ebd62e6dfa005a..87da1f00fc2d17 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -1053,12 +1053,18 @@ public void onStartTemporaryDetach() { public void onAttachedToWindow() { super.onAttachedToWindow(); + int selectionStart = getSelectionStart(); + int selectionEnd = getSelectionEnd(); + // Used to ensure that text is selectable inside of removeClippedSubviews // See https://github.com/facebook/react-native/issues/6805 for original // fix that was ported to here. super.setTextIsSelectable(true); + // Restore the selection since `setTextIsSelectable` changed it. + setSelection(selectionStart, selectionEnd); + if (mContainsImages) { Spanned text = getText(); TextInlineImageSpan[] spans = text.getSpans(0, text.length(), TextInlineImageSpan.class);