Make <TextInput multiline> default blurOnSubmit to false.

Reviewed By: achen1

Differential Revision: D5830633

fbshipit-source-id: 3d0880656f14cfafa0f15c4341021799f20f40ed
This commit is contained in:
Ramanpreet Nara 2017-09-14 11:19:47 -07:00 committed by Facebook Github Bot
parent f568090ae2
commit adb6646016
2 changed files with 18 additions and 20 deletions

View File

@ -9,10 +9,6 @@
package com.facebook.react.views.textinput;
import javax.annotation.Nullable;
import java.util.ArrayList;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Rect;
@ -38,13 +34,14 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.views.text.CustomStyleSpan;
import com.facebook.react.views.text.ReactTagSpan;
import com.facebook.react.views.text.ReactTextUpdate;
import com.facebook.react.views.text.TextInlineImageSpan;
import com.facebook.react.views.view.ReactViewBackgroundDrawable;
import java.util.ArrayList;
import javax.annotation.Nullable;
/**
* A wrapper around the EditText that lets us better control what happens when an EditText gets
@ -76,7 +73,7 @@ public class ReactEditText extends EditText {
private @Nullable TextWatcherDelegator mTextWatcherDelegator;
private int mStagedInputType;
private boolean mContainsImages;
private boolean mBlurOnSubmit;
private @Nullable Boolean mBlurOnSubmit;
private boolean mDisableFullscreen;
private @Nullable String mReturnKeyType;
private @Nullable SelectionWatcher mSelectionWatcher;
@ -102,7 +99,7 @@ public class ReactEditText extends EditText {
mMostRecentEventCount = 0;
mIsSettingTextFromJS = false;
mIsJSSettingFocus = false;
mBlurOnSubmit = true;
mBlurOnSubmit = null;
mDisableFullscreen = false;
mListeners = null;
mTextWatcherDelegator = null;
@ -277,11 +274,16 @@ public class ReactEditText extends EditText {
mSelectionWatcher = selectionWatcher;
}
public void setBlurOnSubmit(boolean blurOnSubmit) {
public void setBlurOnSubmit(@Nullable Boolean blurOnSubmit) {
mBlurOnSubmit = blurOnSubmit;
}
public boolean getBlurOnSubmit() {
if (mBlurOnSubmit == null) {
// Default blurOnSubmit
return isMultiline() ? false : true;
}
return mBlurOnSubmit;
}

View File

@ -9,15 +9,9 @@
package com.facebook.react.views.textinput;
import javax.annotation.Nullable;
import java.lang.reflect.Field;
import java.util.LinkedList;
import java.util.Map;
import android.graphics.drawable.Drawable;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.text.Editable;
import android.text.InputFilter;
@ -30,8 +24,6 @@ import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.TextView;
import com.facebook.yoga.YogaConstants;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.ReactContext;
@ -56,8 +48,12 @@ import com.facebook.react.views.scroll.ScrollEventType;
import com.facebook.react.views.text.DefaultStyleValuesUtil;
import com.facebook.react.views.text.ReactFontManager;
import com.facebook.react.views.text.ReactTextUpdate;
import com.facebook.react.views.text.ReactTextView;
import com.facebook.react.views.text.TextInlineImageSpan;
import com.facebook.yoga.YogaConstants;
import java.lang.reflect.Field;
import java.util.LinkedList;
import java.util.Map;
import javax.annotation.Nullable;
/**
* Manages instances of TextInput.
@ -269,8 +265,8 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
}
}
@ReactProp(name = "blurOnSubmit", defaultBoolean = true)
public void setBlurOnSubmit(ReactEditText view, boolean blurOnSubmit) {
@ReactProp(name = "blurOnSubmit")
public void setBlurOnSubmit(ReactEditText view, @Nullable Boolean blurOnSubmit) {
view.setBlurOnSubmit(blurOnSubmit);
}