Skip to content

Keep ellipsizeMode when adjustsFontSizeToFit is set on Android - #58749

Open
conner1reimers wants to merge 2 commits into
react:mainfrom
conner-reimers:adjusts-font-size-to-fit-ellipsize
Open

conner1reimers wants to merge 2 commits into
react:mainfrom
conner-reimers:adjusts-font-size-to-fit-ellipsize

Conversation

@conner1reimers

@conner1reimers conner1reimers commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

On Android, ReactTextView.updateView() clears the ellipsize location whenever adjustsFontSizeToFit is set. Text that still does not fit after shrinking is clipped instead of being truncated with the requested ellipsizeMode. iOS applies ellipsizeMode regardless of adjustsFontSizeToFit.

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 numberOfLines is set and the text still exceeds it at the minimum font size. TextLayoutManager.adjustSpannableFontToFit() now reports whether that is the case, and ReactTextView keeps the result for updateView(). Applying the ellipsize location unconditionally caused the last glyph of otherwise-fitting text to be clipped, since TextView lays 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 ellipsizeMode to text that still overflows with adjustsFontSizeToFit

Test Plan:

Unit tests

Added coverage for:

  • Applying the ellipsize location while text still exceeds numberOfLines, and removing it once the text fits
  • adjustSpannableFontToFit() 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.text tests 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.

Before After
Android Emulator - Pixel_8_API_355554 2026-09-29 at 5 05 41 PM Android Emulator - Pixel_8_API_355554 2026-09-29 at 5 09 33 PM

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 29, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Sep 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant