From ec5090adab681ce1775bda2526f751b5cf85f863 Mon Sep 17 00:00:00 2001 From: Hank Chen Date: Fri, 6 Nov 2020 11:47:07 -0800 Subject: [PATCH] `Android`: font-family is not apply when secureTextEntry is true (#30164) Summary: This pr fixes: https://github.com/facebook/react-native/issues/30123 . When secureTextEntry is true, setInputType will set the inputType of textInput to password type. Password type default font-family will be monospace font, so we need to setTypeface after the setInputType. ## Changelog [Android] [Fixed] - Font family is not apply when secureTextEntry is true. Pull Request resolved: https://github.com/facebook/react-native/pull/30164 Test Plan: Before this pr: ![alt text](https://i.imgur.com/mAxLhnB.png) After this pr: ![alt text](https://i.imgur.com/zoGYDxN.png) Please initiated a new project and replaced the App.js with the following code: ``` iimport React from 'react'; import {SafeAreaView, TextInput} from 'react-native'; const App = () => { return ( ); }; export default App; ``` Thanks you so much for your code review! Reviewed By: cpojer Differential Revision: D24686222 Pulled By: hramos fbshipit-source-id: 863ebe1dba36cac7d91b2735fe6e914ac839ed44 # Conflicts: # ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java --- .../com/facebook/react/views/textinput/ReactEditText.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index 78a05c5e48d..d1783a39f01 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -383,8 +383,6 @@ public class ReactEditText extends AppCompatEditText { @Override public void setInputType(int type) { Typeface tf = super.getTypeface(); - // Input type password defaults to monospace font, so we need to re-apply the font - super.setTypeface(tf); int inputType = type; @@ -401,6 +399,8 @@ public class ReactEditText extends AppCompatEditText { super.setInputType(inputType); mStagedInputType = inputType; + // Input type password defaults to monospace font, so we need to re-apply the font + super.setTypeface(tf); /** * If set forces multiline on input, because of a restriction on Android source that enables