Skip to content

Commit 00d9dea

Browse files
hank121314facebook-github-bot
authored andcommitted
Android: font-family is not apply when secureTextEntry is true (#30164)
Summary: This pr fixes: #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: #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 ( <SafeAreaView> <TextInput id={'email'} placeholder={'Email'} secureTextEntry={false} style={{fontFamily: 'Helvetica', fontSize: 14, fontWeight: '400'}} /> <TextInput id={'password'} placeholder={'Password'} secureTextEntry={true} style={{fontFamily: 'Helvetica', fontSize: 14, fontWeight: '400'}} /> </SafeAreaView> ); }; export default App; ``` Thanks you so much for your code review! Reviewed By: cpojer Differential Revision: D24686222 Pulled By: hramos fbshipit-source-id: 863ebe1dba36cac7d91b2735fe6e914ac839ed44
1 parent d8b0997 commit 00d9dea

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -419,11 +419,10 @@ public String getReturnKeyType() {
419419
@Override
420420
public void setInputType(int type) {
421421
Typeface tf = super.getTypeface();
422-
// Input type password defaults to monospace font, so we need to re-apply the font
423-
super.setTypeface(tf);
424-
425422
super.setInputType(type);
426423
mStagedInputType = type;
424+
// Input type password defaults to monospace font, so we need to re-apply the font
425+
super.setTypeface(tf);
427426

428427
/**
429428
* If set forces multiline on input, because of a restriction on Android source that enables

0 commit comments

Comments
 (0)