Skip to content

Commit 29f3f55

Browse files
Shin-Kai Chenfacebook-github-bot
Shin-Kai Chen
authored andcommitted
Do not overwrite the same text in ReactEditText
Differential Revision: D6516674 fbshipit-source-id: 246b8efeff7963912bf6b1c8a004c3103be03246
1 parent 098a63a commit 29f3f55

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java

+14
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import android.text.SpannableStringBuilder;
2020
import android.text.Spanned;
2121
import android.text.TextWatcher;
22+
import android.text.TextUtils;
2223
import android.text.method.KeyListener;
2324
import android.text.method.QwertyKeyListener;
2425
import android.text.style.AbsoluteSizeSpan;
@@ -342,6 +343,11 @@ public int incrementAndGetEventCounter() {
342343

343344
// VisibleForTesting from {@link TextInputEventsTestCase}.
344345
public void maybeSetText(ReactTextUpdate reactTextUpdate) {
346+
if( isSecureText() &&
347+
TextUtils.equals(getText(), reactTextUpdate.getText())) {
348+
return;
349+
}
350+
345351
// Only set the text if it is up to date.
346352
mMostRecentEventCount = reactTextUpdate.getJsEventCounter();
347353
if (mMostRecentEventCount < mNativeEventCount) {
@@ -439,6 +445,14 @@ private boolean isMultiline() {
439445
return (getInputType() & InputType.TYPE_TEXT_FLAG_MULTI_LINE) != 0;
440446
}
441447

448+
private boolean isSecureText() {
449+
return
450+
(getInputType() &
451+
(InputType.TYPE_NUMBER_VARIATION_PASSWORD |
452+
InputType.TYPE_TEXT_VARIATION_PASSWORD))
453+
!= 0;
454+
}
455+
442456
private void onContentSizeChange() {
443457
if (mContentSizeWatcher != null) {
444458
mContentSizeWatcher.onLayout();

0 commit comments

Comments
 (0)