From 13cb5a91ed7fa39c6eb6f71f08c97813766c29fa Mon Sep 17 00:00:00 2001 From: David Vacca Date: Mon, 25 Mar 2019 10:12:37 -0700 Subject: [PATCH] Fix IllegalStateException when tapping next on Android Keyboard Summary: This diff fixes an IllegalStateException that is thrown when the user click is on a edit text and tap 'Next' on the keyboard to focus on the next view, but the next view is hidden. Reviewed By: lunaleaps, mmmulani Differential Revision: D14598410 fbshipit-source-id: 2999cc468ed24bedff163eedcfaec50f6ee005d6 --- .../react/views/textinput/ReactTextInputManager.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java index e948c88ab3c8e3..67bafbc242c82e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java @@ -7,6 +7,8 @@ package com.facebook.react.views.textinput; +import static android.view.View.FOCUS_FORWARD; + import android.annotation.TargetApi; import android.graphics.PorterDuff; import android.graphics.Typeface; @@ -882,6 +884,12 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent keyEvent) { // Prevent default behavior except when we want it to insert a newline. return blurOnSubmit || !isMultiline; + } else if (actionId == EditorInfo.IME_ACTION_NEXT) { + View v1 = v.focusSearch(FOCUS_FORWARD); + if (v1 != null && !v.requestFocus(FOCUS_FORWARD)) { + return true; + } + return false; } return true;