1
+ diff --git a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java
2
+ --- a/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java
3
+ +++ b/node_modules/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java
4
+ @@ -418,6 +418,10 @@ public class ReactEditText extends AppCompatEditText {
5
+ return;
6
+ }
7
+
8
+ + maybeSetSelection(start, end);
9
+ + }
10
+ +
11
+ + private void maybeSetSelection(int start, int end) {
12
+ if (start != ReactConstants.UNSET && end != ReactConstants.UNSET) {
13
+ // clamp selection values for safety
14
+ start = clampToTextLength(start);
15
+ @@ -544,7 +548,8 @@ public class ReactEditText extends AppCompatEditText {
16
+ int selectionStart = getSelectionStart();
17
+ int selectionEnd = getSelectionEnd();
18
+ setInputType(mStagedInputType);
19
+ - setSelection(selectionStart, selectionEnd);
20
+ + // Restore the selection
21
+ + maybeSetSelection(selectionStart, selectionEnd);
22
+ }
23
+ }
24
+
25
+ @@ -1063,11 +1068,17 @@ public class ReactEditText extends AppCompatEditText {
26
+ public void onAttachedToWindow() {
27
+ super.onAttachedToWindow();
28
+
29
+ + int selectionStart = getSelectionStart();
30
+ + int selectionEnd = getSelectionEnd();
31
+ +
32
+ // Used to ensure that text is selectable inside of removeClippedSubviews
33
+ // See https://github.com/facebook/react-native/issues/6805 for original
34
+ // fix that was ported to here.
35
+
36
+ super.setTextIsSelectable(true);
37
+ +
38
+ + // Restore the selection since `setTextIsSelectable` changed it.
39
+ + maybeSetSelection(selectionStart, selectionEnd);
40
+
41
+ if (mContainsImages) {
42
+ Spanned text = getText();
0 commit comments