From 233fdfc014bb4b919c7624c90e5dac614479076f Mon Sep 17 00:00:00 2001 From: Jason Safaiyeh Date: Tue, 7 Jan 2020 14:16:20 -0800 Subject: [PATCH] Fix setting keyboardType from breaking autoCapitalize (#27523) Summary: Fix for https://github.com/facebook/react-native/issues/27510. Setting the `InputType.TYPE_CLASS_TEXT` flag when `keyboardType` is null or default breaks autoCapitalize. Handle the case when `keyboardType` is null, default, or invalid type. ## Changelog [Android] [Fixed] - Fix setting keyboardType from breaking autoCapitalize Pull Request resolved: https://github.com/facebook/react-native/pull/27523 Test Plan: Added keyboardType prop to RNTester as so ``` ``` ![fixedKeyboardType](https://user-images.githubusercontent.com/8675043/70872892-c96dec80-1f5f-11ea-8e33-714a67eff581.gif) Reviewed By: makovkastar Differential Revision: D19132261 Pulled By: JoshuaGross fbshipit-source-id: be66f0317ed305425ebcff32046ad4bff06d367f --- .../facebook/react/views/textinput/ReactTextInputManager.java | 4 ++++ 1 file changed, 4 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 ba055c292aa92b..fedddd1f32500d 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 @@ -733,6 +733,10 @@ public void setKeyboardType(ReactEditText view, @Nullable String keyboardType) { // This will supercede secureTextEntry={false}. If it doesn't, due to the way // the flags work out, the underlying field will end up a URI-type field. flagsToSet = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD; + } else { + // This prevents KEYBOARD_TYPE_FLAGS from being set when the keyboardType is + // default, unsupported or null. Setting of this flag breaks the autoCapitalize functionality. + return; } updateStagedInputTypeFlag(view, KEYBOARD_TYPE_FLAGS, flagsToSet); checkPasswordType(view);