mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix toggling between hidden and visible password
Summary: A previous PR broke toggling between visible and non-visible password (basically once a password field was made visible, future updates to the keyboardType were effectively ignored, so the password would always be visible). Original PR: https://github.com/facebook/react-native/pull/27523 Changelog: [Internal] Reviewed By: mdvacca, rodrigos-facebook Differential Revision: D19527245 fbshipit-source-id: a5ab343c8a0c6a608171dbfa5afc7536ff241826
This commit is contained in:
+14
-11
@@ -96,6 +96,10 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
| InputType.TYPE_CLASS_TEXT
|
||||
| InputType.TYPE_CLASS_PHONE
|
||||
| PASSWORD_VISIBILITY_FLAG;
|
||||
private static final int AUTOCAPITALIZE_FLAGS =
|
||||
InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
|
||||
| InputType.TYPE_TEXT_FLAG_CAP_WORDS
|
||||
| InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS;
|
||||
|
||||
private static final String KEYBOARD_TYPE_EMAIL_ADDRESS = "email-address";
|
||||
private static final String KEYBOARD_TYPE_NUMERIC = "numeric";
|
||||
@@ -706,17 +710,13 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
}
|
||||
}
|
||||
|
||||
updateStagedInputTypeFlag(
|
||||
view,
|
||||
InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
|
||||
| InputType.TYPE_TEXT_FLAG_CAP_WORDS
|
||||
| InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS,
|
||||
autoCapitalizeValue);
|
||||
updateStagedInputTypeFlag(view, AUTOCAPITALIZE_FLAGS, autoCapitalizeValue);
|
||||
}
|
||||
|
||||
@ReactProp(name = "keyboardType")
|
||||
public void setKeyboardType(ReactEditText view, @Nullable String keyboardType) {
|
||||
int flagsToSet = InputType.TYPE_CLASS_TEXT;
|
||||
boolean unsettingFlagsBreaksAutocomplete = false;
|
||||
if (KEYBOARD_TYPE_NUMERIC.equalsIgnoreCase(keyboardType)) {
|
||||
flagsToSet = INPUT_TYPE_KEYBOARD_NUMBERED;
|
||||
} else if (KEYBOARD_TYPE_NUMBER_PAD.equalsIgnoreCase(keyboardType)) {
|
||||
@@ -731,12 +731,15 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
// 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;
|
||||
} else if ((view.getStagedInputType() & AUTOCAPITALIZE_FLAGS) != 0) {
|
||||
// This prevents KEYBOARD_TYPE_FLAGS from being unset when the keyboardType is
|
||||
// default, null, or unsupported, and autocapitalize is on.
|
||||
// Unsetting these flags breaks the autoCapitalize functionality.
|
||||
unsettingFlagsBreaksAutocomplete = true;
|
||||
}
|
||||
updateStagedInputTypeFlag(view, KEYBOARD_TYPE_FLAGS, flagsToSet);
|
||||
|
||||
updateStagedInputTypeFlag(
|
||||
view, (unsettingFlagsBreaksAutocomplete ? 0 : KEYBOARD_TYPE_FLAGS), flagsToSet);
|
||||
checkPasswordType(view);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user