Skip to content

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

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

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
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.

1 participant