-
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
[Android] allowFontScaling prop on TextInput does not disable placeholder font scaling #18827
Comments
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions. |
Also in React Native 0.56.0 setting |
Any one have ideas how to solve this in React Native 0.56.0 ? We are blocked and appreciate some direction. |
Yes, I have the same problem. |
@8of @esdlists @QuYunFengg
|
@francismalone i tried, but it's not work :( |
Guys, I faced with the same problem. I created this lib for resolving this issue in my project. Maybe it will help you: https://github.com/NelGarbuzova/react-native-stylized-placeholder .. |
For placeholder fontSize change issue @NelGarbuzova 's solution works. To fix font changing while inputting text the workaround is to -
It will fix your fontSize and won't change because of system settings for both android and iOS. For this workaround don't set allowFontScaling to false. |
@anirudha-ani but your solution don't affect on placeholder size, placeholder still be transformed by user device's settings. |
@NelGarbuzova that's why I have suggested your component along with it to fix placeholder font size |
Currently, the `TextInput's` placeholder is always sized as though `allowFontScaling` is `true`. Note that `allowFontScaling` works fine for the content of the `TextInput`. The reason is that we set the font size in two places: in the shadow node and in the Android view. The shadow node logic determines the size of the content and the Android view logic determines the size of the placeholder. The handler for the `allowFontScaling` prop is only present in the shadow node logic. Consequently, the Android view logic always uses the default value of `true` for the `allowFontScaling` prop. The fix is to add logic for handling the `allowFontScaling` prop to the Android view. It would be great if we could handle all text props in one spot instead of duplicating code between the shadow node and the Android view. That would eliminate this whole class of bugs. However, I don't have enough familiarity with the history of this code to know how hard that would be or if it's even possible. Fixes facebook#18827. Test Plan: ---------- Verified that `Text`, the content of a `TextInput`, and the placeholder of a `TextInput` are all rendered the same way for all values of `allowFontScaling` (`undefined`, `true`, `false`). Changelog: ---------- [Android] [Fixed] - TextInput: Support `allowFontScaling` on placeholder Adam Comella Microsoft Corp.
I have a fix for this: rigdern@d038069 After a prerequisite PR is merged (#22917), I'll send a PR with that fix. |
Currently, the `TextInput's` placeholder is always sized as though `allowFontScaling` is `true`. Note that `allowFontScaling` works fine for the content of the `TextInput`. The reason is that we set the font size in two places: in the shadow node and in the Android view. The shadow node logic determines the size of the content and the Android view logic determines the size of the placeholder. The handler for the `allowFontScaling` prop is only present in the shadow node logic. Consequently, the Android view logic always uses the default value of `true` for the `allowFontScaling` prop. The fix is to add logic for handling the `allowFontScaling` prop to the Android view. It would be great if we could handle all text props in one spot instead of duplicating code between the shadow node and the Android view. That would eliminate this whole class of bugs. However, I don't have enough familiarity with the history of this code to know how hard that would be or if it's even possible. Fixes facebook#18827. Test Plan: ---------- Verified that `Text`, the content of a `TextInput`, and the placeholder of a `TextInput` are all rendered the same way for all values of `allowFontScaling` (`undefined`, `true`, `false`). Changelog: ---------- [Android] [Fixed] - TextInput: Support `allowFontScaling` on placeholder Adam Comella Microsoft Corp.
…k#22992) Summary: Currently, the `TextInput's` placeholder is always sized as though `allowFontScaling` is `true`. Note that `allowFontScaling` works fine for the content of the `TextInput`. The reason is that we set the font size in two places: in the shadow node and in the Android view. The shadow node logic determines the size of the content and the Android view logic determines the size of the placeholder. The handler for the `allowFontScaling` prop is only present in the shadow node logic. Consequently, the Android view logic always uses the default value of `true` for the `allowFontScaling` prop. The fix is to add logic for handling the `allowFontScaling` prop to the Android view. It would be great if we could handle all text props in one spot instead of duplicating code between the shadow node and the Android view. That would eliminate this whole class of bugs. However, I don't have enough familiarity with the history of this code to know how hard that would be or if it's even possible. Fixes facebook#18827. Pull Request resolved: facebook#22992 Differential Revision: D13671400 Pulled By: cpojer fbshipit-source-id: 40bae3cfb0ca6298e91a81c05211538935f5a0e8
I'm using the
allowFontScaling
prop onText
elements andTextInput
elements for some more fine-grained control of the font scaling behavior in my team's app. Specifically, I'm settingallowFontScaling
to false and doing the font scaling manually, so I can cap the font scaling at a reasonable amount. This approach worked for everything except the placeholder text onTextInput
elements on Android. It appears thatallowFontScaling={false}
does not turn off the font scaling for placeholder text.Environment
Environment:
OS: macOS High Sierra 10.13.2
Node: 9.2.0
Yarn: Not Found
npm: 5.8.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.1 AI-173.4670197
Packages: (wanted => installed)
react: 16.3.0-alpha.1 => 16.3.0-alpha.1
react-native: 0.55.0 => 0.55.0
Steps to Reproduce
I have put together a sample project at https://github.com/Elethier/react-native-placeholder-scaling-bug. I reproduced the issue on a Samsung Galaxy J7 running Android 6.0.1 and a Nexus 5X running Android 8.1.0.
I should also note that I was unable to reproduce this issue on a fresh native Android project, which suggests to me that it's a bug specific to React Native.
Expected Behavior
I would expect that if the prop
allowFontScaling
is set to false, both the placeholder text and the user-inserted text would not scale up based on the phone's system font size.Actual Behavior
The placeholder text font size scales up with the system font size, even though the user-inserted text does not. Here is a GIF showing the behavior:
For reference, here is a screenshot of the phone's font size settings. This is on a Samsung Galaxy J7.
The text was updated successfully, but these errors were encountered: