From 752b68857c75a316d8afb5fc7f99d41c0ed68953 Mon Sep 17 00:00:00 2001 From: Peter Ruibal Date: Tue, 10 Oct 2017 18:02:21 -0700 Subject: [PATCH] Add `visible-password` for TextInput.keyboardType on Android Summary: `visible-password` represents a very basic keyboard, typically only letters and numbers. Backed by InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD, it is useful for things like password and code entry fields. It can also be more effective than autoCorrect={false} for disabling autocompletion on some keyboards (like Gboard). Note `secureTextEntry` also affects `TYPE_TEXT_VARIATION_*` flags internally, so there may be some undefined behavior when combining `secureTextEntry` with `keyboardType="visible-password"` Also, while here, improve the documentation on TextInput to explicitly enumerate which keyboardType applies to Android vs. iOS (since this is the first android-specific) Reviewed By: shergin Differential Revision: D6005353 fbshipit-source-id: 13af90c96353f714c0e106dd0fde90184a476533 --- Libraries/Components/TextInput/TextInput.js | 21 +++++++++++++++++++ .../textinput/ReactTextInputManager.java | 3 +++ 2 files changed, 24 insertions(+) diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 4cce22b23..9b96c0d16 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -245,6 +245,25 @@ const TextInput = createReactClass({ * - `numeric` * - `email-address` * - `phone-pad` + * + * *iOS Only* + * + * The following values work on iOS only: + * + * - `ascii-capable` + * - `numbers-and-punctuation` + * - `url` + * - `number-pad` + * - `name-phone-pad` + * - `decimal-pad` + * - `twitter` + * - `web-search` + * + * *Android Only* + * + * The following values work on Android only: + * + * - `visible-password` */ keyboardType: PropTypes.oneOf([ // Cross-platform @@ -261,6 +280,8 @@ const TextInput = createReactClass({ 'decimal-pad', 'twitter', 'web-search', + // Android-only + 'visible-password', ]), /** * Determines the color of the keyboard. 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 44849d3b0..70d9a461b 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 @@ -77,6 +77,7 @@ public class ReactTextInputManager extends BaseViewManager