Skip to content

Commit

Permalink
Do not overwrite the same text in ReactEditText
Browse files Browse the repository at this point in the history
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 29f3f55
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 29f3f55

Please sign in to comment.