mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix secure text entry setting
Summary: We have password components which allow visibility to be toggled by setting both the keyboardType and secureTextEntry props. The order in which those updates are executed is determined by iterating a NativeMap of props, and the iteration order of a NativeMap is implementation dependent. With libc++ as our STL, we observe that setSecureTextEntry is called before setKeyboardType. This results in the following sequence of input type flag settings when toggling the component to visible and then back to hidden: * The field starts out with TYPE_TEXT_VARIATION_PASSWORD (0x80). * When we toggle to visible, setSecureTextEntry is called with password being false, which clears TYPE_TEXT_VARIATION_PASSWORD. setKeyboardType is then called with the visible-password keyboard type, which sets TYPE_TEXT_VARIATION_VISIBLE_PASSWORD (0x90). * When we toggle back to hidden, setSecureTextEntry is called with password being true, which sets TYPE_TEXT_VARIATION_PASSWORD but doesn't clear TYPE_TEXT_VARIATION_VISIBLE_PASSWORD. setKeyboardType is then called with the default keyboard type and additionally sets TYPE_CLASS_TEXT, but TYPE_TEXT_VARIATION_VISIBLE_PASSWORD remains and the password field remains visible. The fix is to clear TYPE_TEXT_VARIATION_VISIBLE_PASSWORD when setSecureTextEntry is called with password being true, to ensure the password gets hidden. Changelog: [Android][Fixed] - Fix secure text entry setting to always hide text Reviewed By: shergin Differential Revision: D23399174 fbshipit-source-id: a81deec702e768672e2103b76ab50ec728dac229
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7d44959940
commit
f19372361f
+1
-1
@@ -707,7 +707,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
updateStagedInputTypeFlag(
|
||||
view,
|
||||
password
|
||||
? 0
|
||||
? InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
|
||||
: InputType.TYPE_NUMBER_VARIATION_PASSWORD | InputType.TYPE_TEXT_VARIATION_PASSWORD,
|
||||
password ? InputType.TYPE_TEXT_VARIATION_PASSWORD : 0);
|
||||
checkPasswordType(view);
|
||||
|
||||
Reference in New Issue
Block a user