You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support arbitrary selectable text in Text component (#1346)
* Support arbitrary selectable text in Text component
Summary:
RN Mac's implementation of the `selectable` prop on `Text` only allows selecting the entire Text component and right click to copy. This diff makes the `Text.selectable` prop on Mac allow arbitrary selection. To do this we used `NSTextView` to render the `Text` component instead of RN Mac's custom text rendering, because it has a `selectable` property which gives us the behavior we want.
We also allow adding custom menu items in the context menu.
Note the change to RNTesterPage.js was required to fix#754.
Test Plan:
See test plan of D27250072 for integration to Zeratul.
Confirmed text selection works in RNTester Text example:
{F588619781}
---
Also I went to RNTester Text examples and did an image diff comparison before and after these changes (differences are in pink):
{F588602710}
- The font smoothing isn't something we need
---
{F588602715}
- The examples with images are different because they load random images
- The pink background on "With size and background color" isn't a difference, the background color is pink in code
---
{F588602706}
- The <TextInput multiline/> example has an off by 1 pixel difference that wasn't trivial to fix and doesn't seem significant enough to investigate
Reviewers: skyle, ericroz
Reviewed By: skyle
Subscribers: eliwhite
Differential Revision: https://phabricator.intern.facebook.com/D27484533
Tasks: T83817888
Signature: 27484533:1617928003:6c1c60a15db8ef3551aafe22229fafc9fea0053e
# Conflicts:
# Libraries/Text/Text/RCTTextView.m
# React/Base/RCTTouchHandler.h
# React/Base/RCTTouchHandler.m
* Fix GH tags
* Revert RNTesterPage style change
* Fix hit-testing in RCTTextView for selection
Summary:
This fixes a regression introduced by D29340382 since the `contentView` of the window was changed to the `RCTRootView` instance. The problem isn't there though, but is due to now the `contentView` having flipped geometry. The `hitTest:` method expects coordinates in the superview's coordinate space:
> A point that is in the coordinate system of the view’s superview, not of the view itself.
Also see how `RCTTouchHandler` also calls `convertPoint:` on the `superview` before passing to `hitTest:` for the same reason: https://fburl.com/diffusion/krx4lxao
Test Plan:
{F628902534}
Reviewers: lyahdav
Reviewed By: lyahdav
Subscribers: eliwhite
Differential Revision: https://phabricator.intern.facebook.com/D29469639
Tasks: T94420821
Signature: 29469639:1625001662:97028699aee404282c83e35cd66f6308bc793a2a
* Revert changes to touch handler
* Only keep NSTextView changes
* Remove unused property
* Re-add focus ring for selected text
* Fix typos
* Ensure that RCTTextView manages the key loop view
* move focusable property lower in list
* Fix macos tags
* Remove iOS only highlighted prop that was causing re-render issues on macOS
* yarn lint
Co-authored-by: Liron Yahdav <[email protected]>
Co-authored-by: Shawn Dempsey <[email protected]>
Co-authored-by: Scott Kyle <[email protected]>
0 commit comments