Skip to content

Refresh padding and text after a pixel density change (#59049) - #59049

Closed
brunocramos wants to merge 1 commit into
react:mainfrom
brunocramos:export-D124076552
Closed

brunocramos wants to merge 1 commit into
react:mainfrom
brunocramos:export-D124076552

Conversation

@brunocramos

@brunocramos brunocramos commented Oct 13, 2026 •

Copy link
Copy Markdown

Summary:

When an Android app handles density changes itself (density in android:configChanges), its surface is laid out again at the new density, but some mounted views keep sizes from the old one:

  • Padding and overflow insets are sent to views in pixels, but only when their dp values change, which a density change usually doesn't do. A TextInput keeps its old pixel padding, so its text and placeholder can be clipped.
  • Paragraph state only updates when the text, its attributes or its measured size change, so Text keeps the layout it built at the old density and draws at the old size.

With the new fixTextLayoutOnPixelDensityChange feature flag on, padding and overflow insets are re-sent when the pixel density changes (zero insets are skipped: they are zero pixels at any density), and paragraph state is rebuilt. Both text paths are covered: with enablePreparedTextLayout, the paragraph prepares a new layout at the new density (the prepared text cache is keyed by density) and its state now updates when only the density changed; without it, the state records the density too. The flag is off by default.

How to use: return true from your app's feature flag overrides, before React Native starts:

override fun fixTextLayoutOnPixelDensityChange(): Boolean = true

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D124076552

@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 Oct 13, 2026
@meta-codesync

meta-codesync Bot commented Oct 13, 2026

Copy link
Copy Markdown

@brunocramos has exported this pull request. If you are a Meta employee, you can view the originating Diff in D124076552.

Summary:

When an Android app handles density changes itself (`density` in `android:configChanges`), its surface is laid out again at the new density, but some mounted views keep sizes from the old one:

- Padding and overflow insets are sent to views in pixels, but only when their dp values change, which a density change usually doesn't do. A `TextInput` keeps its old pixel padding, so its text and placeholder can be clipped.
- Paragraph state only updates when the text, its attributes or its measured size change, so `Text` keeps the layout it built at the old density and draws at the old size.

With the new `fixTextLayoutOnPixelDensityChange` feature flag on, padding and overflow insets are re-sent when the pixel density changes (zero insets are skipped: they are zero pixels at any density), and paragraph state is rebuilt. Both text paths are covered: with `enablePreparedTextLayout`, the paragraph prepares a new layout at the new density (the prepared text cache is keyed by density) and its state now updates when only the density changed; without it, the state records the density too. The flag is off by default.

**How to use:** return `true` from your app's feature flag overrides, before React Native starts:

```
override fun fixTextLayoutOnPixelDensityChange(): Boolean = true
```

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D124076552
@meta-codesync meta-codesync Bot changed the title Refresh padding and text after a pixel density change Refresh padding and text after a pixel density change (#59049) Oct 13, 2026
@meta-codesync meta-codesync Bot closed this in d026c0f Oct 13, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Oct 13, 2026
@meta-codesync

meta-codesync Bot commented Oct 13, 2026

Copy link
Copy Markdown

This pull request has been merged in d026c0f.

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. Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant