Skip to content

fix: paint Android text decorations when a text update keeps the view's frame - #58579

Closed
MatiPl01 wants to merge 1 commit into
react:mainfrom
MatiPl01:fix/android-text-decoration-null-layout
Closed

MatiPl01 wants to merge 1 commit into
react:mainfrom
MatiPl01:fix/android-text-decoration-null-layout

Conversation

@MatiPl01

@MatiPl01 MatiPl01 commented Sep 17, 2026 •

Copy link
Copy Markdown

Summary:

Since #56768 underline and strikethrough are painted by ReactTextView.onDraw through CanvasEffectSpans, and only when getLayout() is non-null. TextView.setText drops the Layout and rebuilds it in onMeasure, but Fabric measures a view only when its frame changed. A text update that keeps the frame (textDecorationLine or textDecorationColor changing on a text that keeps its size) therefore reaches onDraw without a Layout, the decorations are skipped and super.onDraw() paints plain text; they show up only once something else re-measures the view. Reported by @tshmieldev.

onDraw now rebuilds the Layout at the current size before painting the effects; TextView.onDraw would build one for the text anyway.

Changelog:

[ANDROID] [FIXED] - Draw text decorations after a text update that did not change the view's frame

Test Plan:

Android emulator API 34, RN 0.88.0-rc.1. With logging in onDraw, every frame-preserving update arrived as setText -> onDraw with getLayout() == null and no decoration painted, both for setState toggling textDecorationLine and for a Reanimated animation updating it every frame; the same update followed by a frame change painted it.

textDecorationLine cycling none / underline / line-through / underline line-through every 0.75 s, before and after:

before-after-android-textDecorationLine.mp4

@meta-cla

meta-cla Bot commented Sep 17, 2026

Copy link
Copy Markdown

Hi @MatiPl01!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@facebook-github-tools facebook-github-tools Bot added p: Software Mansion Partner: Software Mansion Partner labels Sep 17, 2026
@MatiPl01
MatiPl01 force-pushed the fix/android-text-decoration-null-layout branch from d0ab53e to 9542b15 Compare September 17, 2026 17:33
@MatiPl01 MatiPl01 changed the title fix: draw Android text decorations after frame-preserving text updates fix: paint Android text decorations when a text update keeps the view's frame Sep 17, 2026
@MatiPl01
MatiPl01 force-pushed the fix/android-text-decoration-null-layout branch from 9542b15 to c86e46f Compare September 17, 2026 19:58
ReactTextView.onDraw paints CanvasEffectSpans (underline, strikethrough) only when
getLayout() is non-null. TextView drops its Layout in setText and rebuilds it in
onMeasure, and Fabric measures a view only when its frame changed, so a text state
update that keeps the frame (a decoration or color change on a text of the same
size) reaches onDraw with no Layout and the decorations are skipped until something
else re-measures the view. Rebuild the Layout at the current size before painting;
TextView.onDraw would build one for the plain text anyway.
@MatiPl01
MatiPl01 force-pushed the fix/android-text-decoration-null-layout branch from c86e46f to b642e15 Compare September 18, 2026 09:40
@MatiPl01
MatiPl01 marked this pull request as ready for review September 18, 2026 10:31
@santhosh-umapathi-wikifolio

Copy link
Copy Markdown

Affected by this issue, underline is not visible on Android texts, after re-measure, its thin, not same as before

@j-piasecki

Copy link
Copy Markdown
Contributor

Closing in favor of #58847

@j-piasecki j-piasecki closed this Oct 5, 2026
meta-codesync Bot pushed a commit that referenced this pull request Nov 20, 2026
…'s frame

This is #58579 by @MatiPl01, a fix for a bug I found. Mati is no longer at Software Mansion, so I'm picking this up from my fork. Thanks Mati!

## Summary:

Since #56768 underline and strikethrough are painted by `ReactTextView.onDraw` through `CanvasEffectSpan`s, and only when `getLayout()` is non-null. `TextView.setText` drops the `Layout` and rebuilds it in `onMeasure`, but Fabric measures a view only when its frame changed. A text update that keeps the frame (`textDecorationLine` or `textDecorationColor` changing on a text that keeps its size) therefore reaches `onDraw` without a `Layout`, the decorations are skipped and `super.onDraw()` paints plain text; they show up only once something else re-measures the view.

`onDraw` now rebuilds the `Layout` at the current size before painting the effects; `TextView.onDraw` would build one for the text anyway.

## Changelog:

[ANDROID] [FIXED] - Draw text decorations after a text update that did not change the view's frame

## Test Plan:

Android emulator API 34, RN 0.88.0-rc.1. With logging in `onDraw`, every frame-preserving update arrived as `setText -> onDraw` with `getLayout() == null` and no decoration painted, both for `setState` toggling `textDecorationLine` and for a Reanimated animation updating it every frame; the same update followed by a frame change painted it.

`textDecorationLine` cycling `none` / `underline` / `line-through` / `underline line-through` every 0.75 s, before and after:

https://github.com/user-attachments/assets/7aecf0a9-f999-4f1b-9699-fd07be53cb53

Differential Revision: D129144546

Pull Request resolved: #58847
ntucker pushed a commit to ntucker/chess that referenced this pull request Nov 21, 2026
…on Android

React Native on Android redoes a paragraph's text whenever the paragraph
moves if text sits straight in it, and redone text of the same size is
drawn without its underlines (react/react-native#58579). The credits'
text now all sits in one span, so moving no longer redoes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZDfHd7VmBPMjb2GEkC
ntucker added a commit to ntucker/chess that referenced this pull request Nov 21, 2026
…underlines (#146)

* Put footnote options on their own row when they don't fit beside the lead

On a phone, "Play against" plus five options didn't fit one line, so Full
Stockfish wrapped alone onto an indented, finger-tall second line. The
options now move under the lead as one row, and a wrapped line's first
option lines its text up with the lead's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZDfHd7VmBPMjb2GEkC

* PR screenshots (removed before merge)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZDfHd7VmBPMjb2GEkC

* Keep the credit links' underlines when the settings sheet moves them on Android

React Native on Android redoes a paragraph's text whenever the paragraph
moves if text sits straight in it, and redone text of the same size is
drawn without its underlines (react/react-native#58579). The credits'
text now all sits in one span, so moving no longer redoes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZDfHd7VmBPMjb2GEkC

* Split each footnote option into its own component, and test negated

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZDfHd7VmBPMjb2GEkC

* Remove PR screenshots

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZDfHd7VmBPMjb2GEkC

* Let the footnote's options row shrink so its options wrap on very narrow screens

Flex items don't shrink by default in React Native, so where all options
didn't fit even on a line of their own (a 320 px phone, larger text) the
row overflowed instead of wrapping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5C5ZDfHd7VmBPMjb2GEkC

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p: Software Mansion Partner: Software Mansion Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants