fix: support partial text selection in <Text selectable> - #58363
Open
raajnadar wants to merge 1 commit into
Open
fix: support partial text selection in <Text selectable>#58363raajnadar wants to merge 1 commit into
raajnadar wants to merge 1 commit into
Conversation
…or consistent paragraph rendering
This was referenced Sep 6, 2026
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:
Fixes #13938, open since 2017. Also covers #55187, which reports the same gap as an iOS 26 regression‚ it is not a regression. iOS selection has always copied the whole block.
On iOS,
<Text selectable>installed a long press recogniser and aUIEditMenuInteractionwhose single action copied the entire paragraph. There was no highlight, no drag handles, and no way to take a substring. Android has supported all three since the prop was introduced.Approach
A selectable paragraph now renders through a non-editable
UITextView, which is what provides selection, drag handles and the edit menu on iOS.The care here is in the layout. React Native measures text off the main thread and the drawn result has to match that measurement exactly, so the text view is never allowed to lay anything out itself.
RCTTextLayoutManageralready builds a plain TextKit stack (NSTextStorage,NSLayoutManager,NSTextContainer), andUITextViewaccepts an existing container at initialisation. Handing it the container the paragraph was measured with makes the layout identical by construction rather than by coincidence:The text view is also pinned so it cannot reflow:
widthTracksTextViewandheightTracksTextVieware off,lineFragmentPaddingis zero, and both insets are zero. UIKit performs the selection; React Native keeps the layout.Scope
<Text selectable>takes this path. Every other paragraph draws exactly as before.!TARGET_OS_TV.Behaviour change to be aware of
Copy now copies the selected range rather than the whole paragraph. That is the point of the fix, but an app relying on "long press copies everything" will see a difference.
Changelog:
[IOS] [FIXED] -
<Text selectable>now supports partial text selection, with drag handles and the standard edit menu, instead of copying the whole blockTest Plan:
Tested on RNTester on an iPhone 16 Pro simulator, iOS 18.6, built with:
Before and after were captured on the same simulator, with the same paragraph and the same gesture
Each remaining case rendered a selectable paragraph beside an identical non-selectable control, so any difference is attributable to this change.
onPresson a nested<Text>numberOfLines={2}<View>childyarn formatreports no changes on the three files.