Skip to content

Commit

Permalink
apply pr fix: facebook#18443
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisnojima committed Mar 27, 2018
1 parent 081f70f commit 5c8fa18
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class ReactEditText extends EditText {
private @Nullable ScrollWatcher mScrollWatcher;
private final InternalKeyListener mKeyListener;
private boolean mDetectScrollMovement = false;
private boolean mOnKeyPress = false;

private ReactViewBackgroundManager mReactBackgroundManager;

Expand Down Expand Up @@ -175,7 +176,7 @@ protected void onScrollChanged(int horiz, int vert, int oldHoriz, int oldVert) {
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
ReactContext reactContext = (ReactContext) getContext();
InputConnection inputConnection = super.onCreateInputConnection(outAttrs);
if (inputConnection != null) {
if (inputConnection != null && mOnKeyPress) {
inputConnection = new ReactEditTextInputConnectionWrapper(inputConnection, reactContext, this);
}

Expand Down Expand Up @@ -274,6 +275,10 @@ public void setBlurOnSubmit(@Nullable Boolean blurOnSubmit) {
mBlurOnSubmit = blurOnSubmit;
}

public void setOnKeyPress(boolean onKeyPress) {
mOnKeyPress = onKeyPress;
}

public boolean getBlurOnSubmit() {
if (mBlurOnSubmit == null) {
// Default blurOnSubmit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ public void setOnScroll(final ReactEditText view, boolean onScroll) {
}
}

@ReactProp(name = "onKeyPress", defaultBoolean = false)
public void setOnKeyPress(final ReactEditText view, boolean onKeyPress) {
view.setOnKeyPress(onKeyPress);
}

@ReactProp(name = "placeholder")
public void setPlaceholder(ReactEditText view, @Nullable String placeholder) {
view.setHint(placeholder);
Expand Down

0 comments on commit 5c8fa18

Please sign in to comment.