From 677a78923edaf589fe07f4a5b618d26fc40734b2 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Fri, 5 Jun 2020 16:06:24 +0200 Subject: [PATCH 01/15] fix capitalize characters and position cursor --- .../com/facebook/react/views/textinput/ReactEditText.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 1638b75147d78f..aa29fa2f5429cd 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 @@ -506,7 +506,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); + Integer currentPosition = getSelectionStart(); + getText().clear(); + append(spannableStringBuilder); + setSelection(currentPosition); } mDisableTextDiffing = false; From 80ebff4b6d4ce384598f37e352548cfd1eb0e702 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Fri, 5 Jun 2020 16:07:06 +0200 Subject: [PATCH 02/15] rename variable in java --- .../com/facebook/react/views/textinput/ReactEditText.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 aa29fa2f5429cd..284640ad0eab76 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 @@ -506,10 +506,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. - Integer currentPosition = getSelectionStart(); + Integer startPosition = getSelectionStart(); getText().clear(); append(spannableStringBuilder); - setSelection(currentPosition); + setSelection(startPosition); } mDisableTextDiffing = false; From 7e8eb41fc347b1bbb8931c89e71afe074bcbb2b1 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Wed, 1 Jul 2020 18:12:23 +0200 Subject: [PATCH 03/15] adding test example to RNTester --- RNTester/js/examples/TextInput/TextInputSharedExamples.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/RNTester/js/examples/TextInput/TextInputSharedExamples.js b/RNTester/js/examples/TextInput/TextInputSharedExamples.js index 629991164f97c8..c4b5e5ec9641e2 100644 --- a/RNTester/js/examples/TextInput/TextInputSharedExamples.js +++ b/RNTester/js/examples/TextInput/TextInputSharedExamples.js @@ -91,18 +91,16 @@ class RewriteExample extends React.Component<$FlowFixMeProps, any> { this.state = {text: ''}; } render() { - const limit = 20; + const limit = 100; const remainder = limit - this.state.text.length; const remainderColor = remainder > 5 ? 'blue' : 'red'; return ( { - text = text.replace(/ /g, '_'); + text = text.replace(/ /g, '_').toUpperCase(); this.setState({text}); }} style={styles.default} @@ -457,7 +455,7 @@ module.exports = ([ }, }, { - title: "Live Re-Write ( -> '_') + maxLength", + title: "Live Re-Write ( -> '_' -> toUpperCase) + maxLength", render: function(): React.Node { return ; }, From a66718881611eb687035ff458f7f13befd26f0a3 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Wed, 1 Jul 2020 18:12:41 +0200 Subject: [PATCH 04/15] changing text with setText --- .../java/com/facebook/react/views/textinput/ReactEditText.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 284640ad0eab76..51c6e7d339cf5c 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 @@ -507,8 +507,7 @@ public void maybeSetText(ReactTextUpdate reactTextUpdate) { // try to update state if the wrapper is available. Temporarily disable // to prevent an infinite loop. Integer startPosition = getSelectionStart(); - getText().clear(); - append(spannableStringBuilder); + setText(spannableStringBuilder); setSelection(startPosition); } mDisableTextDiffing = false; From 04ce594557399d149f286d88ee3008773cf9f978 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Sun, 30 Aug 2020 17:17:34 +0200 Subject: [PATCH 05/15] check for reactTextUpdate.length JavaScript Controller TextInput keep their own state and value for the TextInput. This means that the value in Java "This is my word" can be different from the value in JavaScript, in the case of the relevant example we delete spaces from sentence like below "Thisismyword" The two strings have different length, this causes several problems, an example is setSpan(5 ... 5) ends beyond length 4 https://github.com/facebook/react-native/pull/29070#issuecomment-647716585 where we change in JavaScript the TextInput value, but then a setSelection or other operations are triggered in Java with the old parameters. Ideally would be great keeping the same state between Java and JavaScript, but the current solution is checking and handling this scenarios --- .../com/facebook/react/views/textinput/ReactEditText.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 51c6e7d339cf5c..63e0e3ba9643e1 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 @@ -96,6 +96,7 @@ public class ReactEditText extends AppCompatEditText { private int mFontStyle = ReactTypefaceUtils.UNSET; private boolean mAutoFocus = false; private boolean mDidAttachToWindow = false; + private @Nullable Integer mMaximumTextLength = null; private ReactViewBackgroundManager mReactBackgroundManager; @@ -299,7 +300,9 @@ public void maybeSetSelection(int eventCounter, int start, int end) { } if (start != UNSET && end != UNSET) { - setSelection(start, end); + int validStart = (start > mMaximumTextLength) ? mMaximumTextLength : start; + int validEnd = (end > mMaximumTextLength) ? mMaximumTextLength : end; + setSelection(validStart, validEnd); } } @@ -471,6 +474,7 @@ public boolean canUpdateWithEventCount(int eventCounter) { // VisibleForTesting from {@link TextInputEventsTestCase}. public void maybeSetText(ReactTextUpdate reactTextUpdate) { + mMaximumTextLength = reactTextUpdate.getText().length(); if (isSecureText() && TextUtils.equals(getText(), reactTextUpdate.getText())) { return; } @@ -508,6 +512,7 @@ public void maybeSetText(ReactTextUpdate reactTextUpdate) { // to prevent an infinite loop. Integer startPosition = getSelectionStart(); setText(spannableStringBuilder); + mMaximumTextLength = spannableStringBuilder.length(); setSelection(startPosition); } mDisableTextDiffing = false; From bab02b5cae4f7239dfc02df52b46003cebbfba30 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Sun, 30 Aug 2020 17:22:08 +0200 Subject: [PATCH 06/15] Fix RNTester example Pull Request https://github.com/facebook/react-native/pull/29070 solves issue https://github.com/facebook/react-native/issues/11068 by calling setText(string) https://github.com/fabriziobertoglio1987/react-native/blob/a66718881611eb687035ff458f7f13befd26f0a3/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java#L509-L511 but using setText() causes further problems: 1) After setText we need to call setSelection, to position the cursor at the previous state. setText will erase the previous cursor position https://github.com/fabriziobertoglio1987/react-native/blob/a66718881611eb687035ff458f7f13befd26f0a3/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java#L511 2) calling setSelection after setText causes issues with controlled TextInput. The TextInput is keeping its own internal TextInput value state, which is different from the Java version and has different length. https://github.com/facebook/react-native/pull/29070#issuecomment-647716585 This causes erors like below, when Java runs operations like setSelection after setText, as the text in Java is not the JavaScript version of the Text. setSpan(5 ... 5) ends beyond length 4 A solution for this is keeping track of the reactTextUpdate.length sent from JavaScript and saving it as instance variable mMaximumTextLength 3) JavaScript functionality can be included in the library or in ReactNative Application to build fully controller TextInputs. An example is the one included in this diff, where I use onSelectionChange, selection and onChangeText to set from JavaScript the position of the cursor, avoiding to set the cursor in a position higher then text.length The same functionality could be later included in TextInput.js --- .../TextInput/TextInputSharedExamples.js | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/RNTester/js/examples/TextInput/TextInputSharedExamples.js b/RNTester/js/examples/TextInput/TextInputSharedExamples.js index c4b5e5ec9641e2..332925627341c7 100644 --- a/RNTester/js/examples/TextInput/TextInputSharedExamples.js +++ b/RNTester/js/examples/TextInput/TextInputSharedExamples.js @@ -120,18 +120,34 @@ class RewriteExampleInvalidCharacters extends React.Component< > { constructor(props) { super(props); - this.state = {text: ''}; + this.state = {text: '', selection: { start: -1, end: -1 }}; + } + + onSelectionChangeHandler = ({nativeEvent: {selection}}) => { + const { start, end } = selection; + const { text } = this.state; + const maxEnd = text.length; + const validEnd = end > maxEnd ? maxEnd : end; + const validStart = start > maxEnd ? maxEnd : start; + const newSelection = { start: validStart, end: validEnd }; + this.setState({selection: newSelection}, () => console.log("onSelectionChangeHandler selection", this.state.selection)); } + render() { + const { text, selection: { start, end}} = this.state; return ( { - this.setState({text: text.replace(/\s/g, '')}); + const newText = text.replace(/\s/g, ''); + const newEnd = end - 1; + this.setState({text: newText, selection: { start: newEnd, end: newEnd }}); }} + onSelectionChange={this.onSelectionChangeHandler} + selection={{start: start, end: end}} style={styles.default} value={this.state.text} /> From 784a210f2a2ccf43ff80c611e3ba40d5f7469952 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Sun, 30 Aug 2020 17:34:35 +0200 Subject: [PATCH 07/15] remove console.log --- RNTester/js/examples/TextInput/TextInputSharedExamples.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RNTester/js/examples/TextInput/TextInputSharedExamples.js b/RNTester/js/examples/TextInput/TextInputSharedExamples.js index 332925627341c7..3d0c02bd32db87 100644 --- a/RNTester/js/examples/TextInput/TextInputSharedExamples.js +++ b/RNTester/js/examples/TextInput/TextInputSharedExamples.js @@ -130,7 +130,7 @@ class RewriteExampleInvalidCharacters extends React.Component< const validEnd = end > maxEnd ? maxEnd : end; const validStart = start > maxEnd ? maxEnd : start; const newSelection = { start: validStart, end: validEnd }; - this.setState({selection: newSelection}, () => console.log("onSelectionChangeHandler selection", this.state.selection)); + this.setState({selection: newSelection}); } render() { From 0d337da4501e2823d9c653a8e8c33e96dc621bde Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Sat, 12 Sep 2020 17:52:43 +0200 Subject: [PATCH 08/15] fix eslint errors --- .../TextInput/TextInputSharedExamples.js | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js b/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js index 3d0c02bd32db87..60fcc311b14a12 100644 --- a/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js +++ b/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js @@ -120,21 +120,24 @@ class RewriteExampleInvalidCharacters extends React.Component< > { constructor(props) { super(props); - this.state = {text: '', selection: { start: -1, end: -1 }}; + this.state = {text: '', selection: {start: -1, end: -1}}; } onSelectionChangeHandler = ({nativeEvent: {selection}}) => { - const { start, end } = selection; - const { text } = this.state; + const {start, end} = selection; + const {text} = this.state; const maxEnd = text.length; const validEnd = end > maxEnd ? maxEnd : end; const validStart = start > maxEnd ? maxEnd : start; - const newSelection = { start: validStart, end: validEnd }; + const newSelection = {start: validStart, end: validEnd}; this.setState({selection: newSelection}); - } + }; render() { - const { text, selection: { start, end}} = this.state; + const { + text, + selection: {start, end}, + } = this.state; return ( { const newText = text.replace(/\s/g, ''); const newEnd = end - 1; - this.setState({text: newText, selection: { start: newEnd, end: newEnd }}); + this.setState({ + text: newText, + selection: {start: newEnd, end: newEnd}, + }); }} onSelectionChange={this.onSelectionChangeHandler} selection={{start: start, end: end}} From d28ac7bd8bd662ef00d08637388c8ef998e39088 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Tue, 2 Feb 2021 12:02:58 +0100 Subject: [PATCH 09/15] update selection with maybeSetText fixes issue caused by setPosition in a new position higher then text.length(); setSpan(5 ... 5) ends beyond length 4 https://github.com/facebook/react-native/pull/29070#issuecomment-647716585 --- .../java/com/facebook/react/views/textinput/ReactEditText.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 bfa19f3ef4dbeb..bdafb4a91c039b 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 @@ -558,9 +558,10 @@ public void maybeSetText(ReactTextUpdate reactTextUpdate) { // try to update state if the wrapper is available. Temporarily disable // to prevent an infinite loop. Integer startPosition = getSelectionStart(); + Integer endPosition = getSelectionEnd(); setText(spannableStringBuilder); mMaximumTextLength = spannableStringBuilder.length(); - setSelection(startPosition); + maybeSetSelection(incrementAndGetEventCounter(), startPosition, endPosition); } mDisableTextDiffing = false; From f8aea2132ff62470245fbbbc5d0dc6a6a83af303 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Tue, 2 Feb 2021 12:04:10 +0100 Subject: [PATCH 10/15] rn-tester - remove changes to examples --- .../TextInput/TextInputSharedExamples.js | 37 +++++-------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js b/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js index 1b5701333f1ebf..556a8a3a1bbaa3 100644 --- a/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js +++ b/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js @@ -91,16 +91,18 @@ class RewriteExample extends React.Component<$FlowFixMeProps, any> { this.state = {text: ''}; } render() { - const limit = 100; + const limit = 20; const remainder = limit - this.state.text.length; const remainderColor = remainder > 5 ? 'blue' : 'red'; return ( { - text = text.replace(/ /g, '_').toUpperCase(); + text = text.replace(/ /g, '_'); this.setState({text}); }} style={styles.default} @@ -120,40 +122,18 @@ class RewriteExampleInvalidCharacters extends React.Component< > { constructor(props) { super(props); - this.state = {text: '', selection: {start: -1, end: -1}}; + this.state = {text: ''}; } - - onSelectionChangeHandler = ({nativeEvent: {selection}}) => { - const {start, end} = selection; - const {text} = this.state; - const maxEnd = text.length; - const validEnd = end > maxEnd ? maxEnd : end; - const validStart = start > maxEnd ? maxEnd : start; - const newSelection = {start: validStart, end: validEnd}; - this.setState({selection: newSelection}); - }; - render() { - const { - text, - selection: {start, end}, - } = this.state; return ( { - const newText = text.replace(/\s/g, ''); - const newEnd = end - 1; - this.setState({ - text: newText, - selection: {start: newEnd, end: newEnd}, - }); + this.setState({text: text.replace(/\s/g, '')}); }} - onSelectionChange={this.onSelectionChangeHandler} - selection={{start: start, end: end}} style={styles.default} value={this.state.text} /> @@ -477,7 +457,8 @@ module.exports = ([ }, }, { - title: "Live Re-Write ( -> '_' -> toUpperCase) + maxLength", + name: 'maxLength', + title: "Live Re-Write ( -> '_') + maxLength", render: function(): React.Node { return ; }, From 76cd475cfb37d87303e016630f337e436464ce17 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Tue, 2 Feb 2021 16:42:57 +0100 Subject: [PATCH 11/15] avoid increasing count when changing cursor Position --- .../java/com/facebook/react/views/textinput/ReactEditText.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 bdafb4a91c039b..76940b1ef8d652 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 @@ -561,7 +561,7 @@ public void maybeSetText(ReactTextUpdate reactTextUpdate) { Integer endPosition = getSelectionEnd(); setText(spannableStringBuilder); mMaximumTextLength = spannableStringBuilder.length(); - maybeSetSelection(incrementAndGetEventCounter(), startPosition, endPosition); + maybeSetSelection(mNativeEventCount, startPosition, endPosition); } mDisableTextDiffing = false; From 1ec343b529cbe7f17298751145013633be07dc1f Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Tue, 2 Feb 2021 16:43:19 +0100 Subject: [PATCH 12/15] update TextInput Example Title --- .../rn-tester/js/examples/TextInput/TextInputSharedExamples.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js b/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js index 556a8a3a1bbaa3..025a3ef39e47f4 100644 --- a/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js +++ b/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js @@ -102,7 +102,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} From 3354c318d1fa3d8159e7b3f67d5c293981ee7f6f Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Tue, 2 Feb 2021 17:47:00 +0100 Subject: [PATCH 13/15] set mMaximumLength initial value to 0 --- .../java/com/facebook/react/views/textinput/ReactEditText.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 76940b1ef8d652..dfa41c8952d078 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 @@ -111,7 +111,7 @@ public class ReactEditText extends AppCompatEditText private int mFontStyle = ReactTypefaceUtils.UNSET; private boolean mAutoFocus = false; private boolean mDidAttachToWindow = false; - private @Nullable Integer mMaximumTextLength = null; + private Integer mMaximumTextLength = 0; private ReactViewBackgroundManager mReactBackgroundManager; From 7ecdea7b885bbb0555ae85913f8ec4fae2fd21c0 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Tue, 18 Jan 2022 16:37:52 +0800 Subject: [PATCH 14/15] revert changes to maybeSetSelection mMaximumTextLength was added to fix the error described in https://github.com/facebook/react-native/pull/29070#issuecomment-683436866 : ``` setSpan(5 ... 5) ends beyond length 4 ``` A similar fix was merged in master with commit https://github.com/facebook/react-native/commit/de44184e01d74e4da18f1cba9b01d4c259ef5d9c, I reverted this changes as the existing solution seems to fix this error. --- .../java/com/facebook/react/views/textinput/ReactEditText.java | 3 --- 1 file changed, 3 deletions(-) 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 7255272993e744..3ac441e1fa0285 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 @@ -111,7 +111,6 @@ public class ReactEditText extends AppCompatEditText private int mFontStyle = UNSET; private boolean mAutoFocus = false; private boolean mDidAttachToWindow = false; - private Integer mMaximumTextLength = 0; private ReactViewBackgroundManager mReactBackgroundManager; @@ -522,7 +521,6 @@ public boolean canUpdateWithEventCount(int eventCounter) { // VisibleForTesting from {@link TextInputEventsTestCase}. public void maybeSetText(ReactTextUpdate reactTextUpdate) { - mMaximumTextLength = reactTextUpdate.getText().length(); if (isSecureText() && TextUtils.equals(getText(), reactTextUpdate.getText())) { return; } @@ -569,7 +567,6 @@ public void maybeSetText(ReactTextUpdate reactTextUpdate) { Integer startPosition = getSelectionStart(); Integer endPosition = getSelectionEnd(); setText(spannableStringBuilder); - mMaximumTextLength = spannableStringBuilder.length(); maybeSetSelection(mNativeEventCount, startPosition, endPosition); } mDisableTextDiffing = false; From b86f4985ca25320301fd8196505ec5ca52e017d0 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Fri, 18 Mar 2022 11:28:59 +0800 Subject: [PATCH 15/15] use int insted of Integer code review https://github.com/facebook/react-native/pull/29070#discussion_r678552497 --- .../com/facebook/react/views/textinput/ReactEditText.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 3ac441e1fa0285..18726f2858ba87 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,8 +564,8 @@ 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. - Integer startPosition = getSelectionStart(); - Integer endPosition = getSelectionEnd(); + int startPosition = getSelectionStart(); + int endPosition = getSelectionEnd(); setText(spannableStringBuilder); maybeSetSelection(mNativeEventCount, startPosition, endPosition); }