Skip to content

Skip empty text decoration draws (#59050) - #59050

Open
Abbondanzo wants to merge 2 commits into
react:mainfrom
Abbondanzo:export-D125038370
Open

Abbondanzo wants to merge 2 commits into
react:mainfrom
Abbondanzo:export-D125038370

Conversation

@Abbondanzo

@Abbondanzo Abbondanzo commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

drawSpannedDecoration now skips zero-line layouts and empty or fully hidden spans before measuring or drawing. Add native regression coverage for the clamped ranges.

Changelog:
[Android][Fixed] - Skip empty and fully hidden text decoration ranges

Differential Revision: D125038370

…t#58366)

Summary:
On Android, a `Text` with `numberOfLines` can crash when a nested `Text` has `textDecorationLine: 'underline'` or `'line-through'` and the decorated span starts or ends past what the truncated layout actually rendered. `drawSpannedDecoration()` reads `start`/`end` from the full, untruncated `Spanned` text and passes them straight to `Layout.getPrimaryHorizontal()`, which throws `IndexOutOfBoundsException` once numberOfLines cuts the layout shorter than the span.

This clamps both offsets to the last position the truncated (and possibly tail-ellipsized) layout can actually resolve before using them, so a partially hidden span draws its decoration up to the visible boundary and a fully hidden span draws nothing, instead of crashing.

## Changelog:

[ANDROID] [FIXED] - Fix crash drawing text decoration (underline/strikethrough) when a nested Text's span extends past a numberOfLines-truncated layout

Pull Request resolved: react#58366

Test Plan:
Added two regression tests in `TextDecorationStyleTest`: both build a single-line, tail-ellipsized `StaticLayout`. One checks clipping a span that starts visible and extends beyond the layout; the other checks the zero-length line for a fully hidden span.

The formatting/API-annotation correction leaves the production source, test bodies, and assertions unchanged. Exact parent test run: https://www.internalfb.com/intern/testinfra/testrun/20829148333669211.

Fixes react#58356

Differential Revision: D125060226

Pulled By: Abbondanzo
@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

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

@meta-codesync meta-codesync Bot changed the title Skip empty text decoration draws Skip empty text decoration draws (#59050) Oct 13, 2026
Abbondanzo added a commit to Abbondanzo/react-native that referenced this pull request Oct 13, 2026
Summary:
Pull Request resolved: react#59050

`drawSpannedDecoration` now skips zero-line layouts and empty or fully hidden spans before measuring or drawing. Add native regression coverage for the clamped ranges.

Changelog:
[Android][Fixed] - Skip empty and fully hidden text decoration ranges

Differential Revision: D125038370
Summary:
Pull Request resolved: react#59050

`drawSpannedDecoration` now skips zero-line layouts and empty or fully hidden spans before measuring or drawing. Add native regression coverage for the clamped ranges.

Changelog:
[Android][Fixed] - Skip empty and fully hidden text decoration ranges

Differential Revision: D125038370

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. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants