From f19372361f22201a453ff38eb69c5fa052b57474 Mon Sep 17 00:00:00 2001 From: Shoaib Meenai Date: Fri, 28 Aug 2020 16:11:19 -0700 Subject: [PATCH] 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 --- .../facebook/react/views/textinput/ReactTextInputManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ec3bb9a4010acc..5e044b283cfa54 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 @@ -707,7 +707,7 @@ public void setSecureTextEntry(ReactEditText view, boolean password) { 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);