fix: support partial text selection in <Text selectable> - #58363
Open
raajnadar wants to merge 2 commits into
Open
fix: support partial text selection in <Text selectable>#58363raajnadar wants to merge 2 commits into
raajnadar wants to merge 2 commits into
Conversation
…or consistent paragraph rendering
This was referenced Sep 6, 2026
Contributor
|
This is quite a change in behaviour. Should these be separate properties so developers can choose which one they want? |
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:
On iOS,
<Text selectable>can only copy the whole paragraph. There is no highlight and no drag handles, so you cannot select part of it. Android has allowed this since the prop was added.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.
Approach
A selectable paragraph now renders in a non-editable
UITextView. The text view is created with the sameNSTextContainerthatRCTTextLayoutManageralready used to measure the paragraph, so the layout is unchanged and UIKit only handles the selection: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.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.