diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 3caf05f6bac..9e4f29c94c9 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -253,6 +253,7 @@ type AndroidProps = $ReadOnly<{| | 'yes' | 'yesExcludeDescendants' ), + showSoftInputOnFocus?: ?boolean, |}>; type Props = $ReadOnly<{| @@ -926,6 +927,12 @@ const TextInput = createReactClass({ 'newPassword', 'oneTimeCode', ]), + /** + * When `false`, it will prevent the soft keyboard from showing when the field is focused. + * Defaults to `true`. + * @platform android + */ + showSoftInputOnFocus: PropTypes.bool, }, getDefaultProps() { return { diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index 63a941a0c2a..7f8137c9c4a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -213,7 +213,9 @@ public class ReactEditText extends EditText { } setFocusableInTouchMode(true); boolean focused = super.requestFocus(direction, previouslyFocusedRect); - showSoftKeyboard(); + if (getShowSoftInputOnFocus()) { + showSoftKeyboard(); + } return focused; } 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 2927ab9c705..e0e286ead83 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 @@ -715,6 +715,12 @@ public class ReactTextInputManager extends BaseViewManager