Keep ellipsizeMode when adjustsFontSizeToFit is set on Android - #58749
Open
conner1reimers wants to merge 2 commits into
Open
conner1reimers wants to merge 2 commits into
conner1reimers wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
On Android,
ReactTextView.updateView()clears the ellipsize location wheneveradjustsFontSizeToFitis set. Text that still does not fit after shrinking is clipped instead of being truncated with the requestedellipsizeMode. iOS appliesellipsizeModeregardless ofadjustsFontSizeToFit.The original Android implementation cleared it deliberately to avoid incorrect ellipsizing while the text is being shrunk (#26389 (comment)). With #58492, Android now respects
minimumFontScale, so shrinking can stop while the text is still too large.This PR applies the ellipsize location when
numberOfLinesis set and the text still exceeds it at the minimum font size.TextLayoutManager.adjustSpannableFontToFit()now reports whether that is the case, andReactTextViewkeeps the result forupdateView(). Applying the ellipsize location unconditionally caused the last glyph of otherwise-fitting text to be clipped, sinceTextViewlays text out slightly wider when an ellipsize is set than the fit loop measures without one.This was split out of #58492.
Changelog:
[ANDROID] [FIXED] - Apply
ellipsizeModeto text that still overflows withadjustsFontSizeToFitTest Plan:
Unit tests
Added coverage for:
numberOfLines, and removing it once the text fitsadjustSpannableFontToFit()returning the expected result when text fits, exceeds the allowed number of lines, or only exceeds the available height./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests 'com.facebook.react.views.text.*'All 48
com.facebook.react.views.texttests pass, including the new cases.RNTester
With #58492, the "Can limit how small the text becomes with minimumFontScale" line in the Android Text example stops at 50% of its font size. Before this change, the overflow is clipped; after, it ends in an ellipsis.