mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-09 22:43:10 +08:00
Enable blurOnSubmit for text input in android
Summary:PR for https://github.com/facebook/react-native/issues/6098, Added tests to UIExplorer based on existing iOS example. Before:  After:  Closes https://github.com/facebook/react-native/pull/6215 Differential Revision: D3000042 Pulled By: mkonicek fb-gh-sync-id: 7f01270580b198498505d92e38a456c0b3a01488 shipit-source-id: 7f01270580b198498505d92e38a456c0b3a01488
This commit is contained in:
committed by
Facebook Github Bot 4
parent
f827f7b79a
commit
ab12189f87
@@ -67,6 +67,7 @@ public class ReactEditText extends EditText {
|
||||
private @Nullable TextWatcherDelegator mTextWatcherDelegator;
|
||||
private int mStagedInputType;
|
||||
private boolean mContainsImages;
|
||||
private boolean mBlurOnSubmit;
|
||||
private @Nullable SelectionWatcher mSelectionWatcher;
|
||||
private final InternalKeyListener mKeyListener;
|
||||
|
||||
@@ -84,6 +85,7 @@ public class ReactEditText extends EditText {
|
||||
mNativeEventCount = 0;
|
||||
mIsSettingTextFromJS = false;
|
||||
mIsJSSettingFocus = false;
|
||||
mBlurOnSubmit = true;
|
||||
mListeners = null;
|
||||
mTextWatcherDelegator = null;
|
||||
mStagedInputType = getInputType();
|
||||
@@ -179,6 +181,14 @@ public class ReactEditText extends EditText {
|
||||
mSelectionWatcher = selectionWatcher;
|
||||
}
|
||||
|
||||
public void setBlurOnSubmit(boolean blurOnSubmit) {
|
||||
mBlurOnSubmit = blurOnSubmit;
|
||||
}
|
||||
|
||||
public boolean getBlurOnSubmit() {
|
||||
return mBlurOnSubmit;
|
||||
}
|
||||
|
||||
/*protected*/ int getStagedInputType() {
|
||||
return mStagedInputType;
|
||||
}
|
||||
|
||||
@@ -181,6 +181,11 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
}
|
||||
}
|
||||
|
||||
@ReactProp(name = "blurOnSubmit", defaultBoolean = true)
|
||||
public void setBlurOnSubmit(ReactEditText view, boolean blurOnSubmit) {
|
||||
view.setBlurOnSubmit(blurOnSubmit);
|
||||
}
|
||||
|
||||
@ReactProp(name = "placeholder")
|
||||
public void setPlaceholder(ReactEditText view, @Nullable String placeholder) {
|
||||
view.setHint(placeholder);
|
||||
@@ -493,7 +498,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
SystemClock.nanoTime(),
|
||||
editText.getText().toString()));
|
||||
}
|
||||
return false;
|
||||
return !editText.getBlurOnSubmit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user