-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fix] Android
: font-family is not apply when secureTextEntry is true
#30164
[Fix] Android
: font-family is not apply when secureTextEntry is true
#30164
Conversation
Base commit: 4d247fe |
Base commit: 4d247fe |
I am using expo SDK 39.0.2 and I also encounter the font family issue with password fields but from the code your fix should not help. Interestingly, in the emulator it works fine but once it is on a real device it fails to correctly style the placeholder. in that version setInputType looks like this: @Override
public void setInputType(int type) {
Typeface tf = super.getTypeface();
super.setInputType(type);
mStagedInputType = type;
// 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
* multiline only for inputs of type Text and Multiline on method {@link
* android.widget.TextView#isMultilineInputType(int)}} Source: {@Link <a
* href='https://android.googlesource.com/platform/frameworks/base/+/jb-release/core/java/android/widget/TextView.java'>TextView.java</a>}
*/
if (isMultiline()) {
setSingleLine(false);
}
// We override the KeyListener so that all keys on the soft input keyboard as well as hardware
// keyboards work. Some KeyListeners like DigitsKeyListener will display the keyboard but not
// accept all input from it
mKeyListener.setInputType(type);
setKeyListener(mKeyListener);
} |
I am facing the same problem here... |
I tried the patch (not using expo) but it didn't fix the issue. |
Hi @wcandillon |
@hank121314 oh I see, I didn't build from source, sorry about that. Going through the instructions now. |
How can i implement it temporarily to publish app with correct font? |
Hi @ramazanarslan . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hramos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This pull request was successfully merged by @hank121314 in 00d9dea. When will my fix make it into a release? | Upcoming Releases |
…ebook#30164) Summary: This pr fixes: facebook#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: facebook#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
) 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 # Conflicts: # ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java
…ebook#30164) Summary: This pr fixes: facebook#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: facebook#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
…ebook#30164) Summary: This pr fixes: facebook#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: facebook#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 (cherry picked from commit 00d9dea)
) 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
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.
Test Plan
Before this pr:
After this pr:
Please initiated a new project and replaced the App.js with the following code:
Thanks you so much for your code review!