diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index 360de688d54849..bd8b06c52f7690 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -564,7 +564,10 @@ public void maybeSetText(ReactTextUpdate reactTextUpdate) { // When we update text, we trigger onChangeText code that will // try to update state if the wrapper is available. Temporarily disable // to prevent an infinite loop. - getText().replace(0, length(), spannableStringBuilder); + int startPosition = getSelectionStart(); + int endPosition = getSelectionEnd(); + setText(spannableStringBuilder); + maybeSetSelection(mNativeEventCount, startPosition, endPosition); } mDisableTextDiffing = false; diff --git a/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js b/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js index 19e758f2a7dd5a..2833a068fb1139 100644 --- a/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js +++ b/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js @@ -104,7 +104,7 @@ class RewriteExample extends React.Component<$FlowFixMeProps, any> { multiline={false} maxLength={limit} onChangeText={text => { - text = text.replace(/ /g, '_'); + text = text.replace(/ /g, '_').toUpperCase(); this.setState({text}); }} style={styles.default}