-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
Text with adjustFontSizeToFit and numberOfLine equal to 1 leads to text being cut off or having extra width #47045
Comments
@itsramiel is this happening also on New Architecture? @coado @j-piasecki do you have any context on this one? |
Yes same behavior on new arch. Can be test on |
@cortinico Nothing from the top of my head, but we can take a closer look at this. |
This is an interesting one. The code for scaling down the font size when |
@j-piasecki Interesting finding. That is consistent with the seen effect, where it only happens to single character in the screenshots above. Do you have a fix in mind, is it easy to implement? |
@itsramiel I'm not sure whether it's the perfect solution, but I've opened a PR which is fixing the problem in the repro you've provided. Could you verify that it works for you? |
I am not sure what the easiest way to test it, but I copied your changes to my react-native files in my node_modules. iOS worked but Android didnt. I tried with a nightly version of react native and got the same result. However, it could easily be that I am copying the code wrongly or missing something, so I would love to know the easiest way to test this. |
Android doesn't work with patch package unless you enable build from source: |
Thank you, now able to test!
Tested and seems to work!! Maybe add some reviewers to collect feedback? |
We're discussing the PR internally and we'll get back to you whenever we can (please note that this week we might be slower to respond and do reviews than usual) |
I had a similar issue using this on react native 0.76.1 using iOS it's caused a little bit differently by a setting the lineHeight bigger then the original fontSize: result it completely glitches out per render cycle either by a too small font or sometimes back to normal. |
@YasinAkimura Thanks. Running into same issue on 0.76.3 (iOS and Android), removing the lineHeight also helped in my case and on both platforms. My texts got miniturized as soon as an adjust was neccesary. |
Description
I have a row of the 3 items. Each item contains two texts. I want that the left text shrinks in size if needed, so I have set
flexShrink: 1
, adjustFontSizeToFit, andnumberOfLines={1}
. While it works for some, it breaks for others in two ways:The text is for some reason cut off
Android:
iOS:
The text is taking more space than needed:
Android:
iOS: doesnt seem to happen here
Steps to reproduce
React Native Version
0.75.4
Affected Platforms
Runtime - Android, Runtime - iOS
Output of
npx react-native info
Reproducer
https://github.com/itsramiel/SingleLineText
Screenshots and Videos
Simulator.Screen.Recording.-.iPhone.15.-.2024-10-16.at.09.40.21.mp4
Screen.Recording.2024-10-16.at.9.39.42.AM.mov
The text was updated successfully, but these errors were encountered: