Permalink
Browse files

Do not overwrite the same text in ReactEditText

Differential Revision: D6516674

fbshipit-source-id: 246b8efeff7963912bf6b1c8a004c3103be03246
  • Loading branch information...
Shin-Kai Chen authored and facebook-github-bot committed Dec 12, 2017
1 parent 098a63a commit 29f3f5529827579101f0d8bd6afe72f1cb0caeca
Showing with 14 additions and 0 deletions.
  1. +14 −0 ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java
@@ -19,6 +19,7 @@
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextWatcher;
import android.text.TextUtils;
import android.text.method.KeyListener;
import android.text.method.QwertyKeyListener;
import android.text.style.AbsoluteSizeSpan;
@@ -342,6 +343,11 @@ public int incrementAndGetEventCounter() {
// VisibleForTesting from {@link TextInputEventsTestCase}.
public void maybeSetText(ReactTextUpdate reactTextUpdate) {
if( isSecureText() &&
TextUtils.equals(getText(), reactTextUpdate.getText())) {
return;
}
// Only set the text if it is up to date.
mMostRecentEventCount = reactTextUpdate.getJsEventCounter();
if (mMostRecentEventCount < mNativeEventCount) {
@@ -439,6 +445,14 @@ private boolean isMultiline() {
return (getInputType() & InputType.TYPE_TEXT_FLAG_MULTI_LINE) != 0;
}
private boolean isSecureText() {
return
(getInputType() &
(InputType.TYPE_NUMBER_VARIATION_PASSWORD |
InputType.TYPE_TEXT_VARIATION_PASSWORD))
!= 0;
}
private void onContentSizeChange() {
if (mContentSizeWatcher != null) {
mContentSizeWatcher.onLayout();

0 comments on commit 29f3f55

Please sign in to comment.