Repository navigation
Skip empty text decoration draws (#59050) - #59050
Open
Abbondanzo wants to merge 2 commits into
Open
Abbondanzo wants to merge 2 commits into
Abbondanzo wants to merge 2 commits into
Conversation
…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
|
@Abbondanzo has exported this pull request. If you are a Meta employee, you can view the originating Diff in D125038370. |
Abbondanzo
force-pushed
the
export-D125038370
branch
from
October 13, 2026 23:27
34d0045 to
d6bca31
Compare
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
Abbondanzo
force-pushed
the
export-D125038370
branch
from
October 13, 2026 23:34
d6bca31 to
f17f412
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
drawSpannedDecorationnow 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