Skip to content

Commit f193723

Browse files
smeenaifacebook-github-bot
authored andcommitted
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
1 parent 7d44959 commit f193723

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ public void setSecureTextEntry(ReactEditText view, boolean password) {
707707
updateStagedInputTypeFlag(
708708
view,
709709
password
710-
? 0
710+
? InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
711711
: InputType.TYPE_NUMBER_VARIATION_PASSWORD | InputType.TYPE_TEXT_VARIATION_PASSWORD,
712712
password ? InputType.TYPE_TEXT_VARIATION_PASSWORD : 0);
713713
checkPasswordType(view);

0 commit comments

Comments
 (0)