Skip to content

[Native] Add RCTSelectableText as a recognized Text component#35780

Open
NickGerleman wants to merge 4 commits intofacebook:mainfrom
NickGerleman:add-more-text
Open

[Native] Add RCTSelectableText as a recognized Text component#35780
NickGerleman wants to merge 4 commits intofacebook:mainfrom
NickGerleman:add-more-text

Conversation

@NickGerleman
Copy link

@NickGerleman NickGerleman commented Feb 13, 2026

Summary

Add "RCTSelectableText" to the list of component names recognized as being inside a text element, alongside "RCTText". When React Facsimile is enabled, the React Native Text component uses different native components (RCTText vs RCTSelectableText), and both need to be recognized to correctly determine the text context.

This would really ideally work a different way, where RN internals could decide this, using e.g. presence of TextAncestorContext.

How did you test this change?

When I patch this in, alongside facebook/react-native#55552, we no longer see warnings when we render text inside of RCTSelectableText component.

Add "RCTSelectableText" to the list of component names recognized as
being inside a text element, alongside "RCTText". When React Facsimile
is enabled, the React Native Text component uses different native
components (RCTText vs RCTSelectableText), and both need to be
recognized to correctly determine the text context.
@react-sizebot
Copy link

react-sizebot commented Feb 13, 2026

Comparing: e8c6362...a33bfb6

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB = 1.88 kB 1.88 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 611.02 kB 611.02 kB = 108.00 kB 108.00 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.84 kB 6.84 kB = 1.88 kB 1.88 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 676.95 kB 676.95 kB = 118.97 kB 118.97 kB
facebook-www/ReactDOM-prod.classic.js = 697.68 kB 697.68 kB = 122.67 kB 122.67 kB
facebook-www/ReactDOM-prod.modern.js = 687.99 kB 687.99 kB = 121.05 kB 121.05 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against a33bfb6

type === 'RCTMultilineTextInputView' || // iOS
type === 'RCTSinglelineTextInputView' || // iOS
type === 'RCTText' ||
type === 'RCTSelectableText' ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the other ones are alphabetized...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed it for you

NickGerleman added a commit to NickGerleman/react-native that referenced this pull request Feb 14, 2026
Summary:
enablePreparedTextLayout replaces ReactTextView (a real TextView) with PreparedLayoutTextView (a ViewGroup that draws a pre-computed Layout). PreparedLayoutTextView does not support native text selection, so selectable text was broken when the flag was on (T222052152).

This diff adds support for selectable text by routing it through ReactTextView when enablePreparedTextLayout is enabled. A new JS component NativeSelectableText resolves to native name RCTSelectableText when the flag is on, or falls back to RCTText when it is off. Text.js uses NativeSelectableText whenever text is selectable, and a new SelectableTextViewManager (which extends ReactTextViewManager) is registered as RCTSelectableText in all ReactPackage sites.

ReactTextViewManager.updateState() is also updated to handle ReferenceStateWrapper holding PreparedLayout, so that it can process state delivered through the PreparedLayout path.

Note that this change relies on facebook/react#35780 to avoid warnings from React

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D92928315
NickGerleman added a commit to NickGerleman/react-native that referenced this pull request Feb 14, 2026
…cebook#55552)

Summary:
Pull Request resolved: facebook#55552

enablePreparedTextLayout replaces ReactTextView (a real TextView) with PreparedLayoutTextView (a ViewGroup that draws a pre-computed Layout). PreparedLayoutTextView does not support native text selection, so selectable text was broken when the flag was on (T222052152).

This diff adds support for selectable text by routing it through ReactTextView when enablePreparedTextLayout is enabled. A new JS component NativeSelectableText resolves to native name RCTSelectableText when the flag is on, or falls back to RCTText when it is off. Text.js uses NativeSelectableText whenever text is selectable, and a new SelectableTextViewManager (which extends ReactTextViewManager) is registered as RCTSelectableText in all ReactPackage sites.

ReactTextViewManager.updateState() is also updated to handle ReferenceStateWrapper holding PreparedLayout, so that it can process state delivered through the PreparedLayout path.

Note that this change relies on facebook/react#35780 to avoid warnings from React

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D92928315
NickGerleman added a commit to NickGerleman/react-native that referenced this pull request Feb 14, 2026
…cebook#55552)

Summary:
Pull Request resolved: facebook#55552

enablePreparedTextLayout replaces ReactTextView (a real TextView) with PreparedLayoutTextView (a ViewGroup that draws a pre-computed Layout). PreparedLayoutTextView does not support native text selection, so selectable text was broken when the flag was on (T222052152).

This diff adds support for selectable text by routing it through ReactTextView when enablePreparedTextLayout is enabled. A new JS component NativeSelectableText resolves to native name RCTSelectableText when the flag is on, or falls back to RCTText when it is off. Text.js uses NativeSelectableText whenever text is selectable, and a new SelectableTextViewManager (which extends ReactTextViewManager) is registered as RCTSelectableText in all ReactPackage sites.

ReactTextViewManager.updateState() is also updated to handle ReferenceStateWrapper holding PreparedLayout, so that it can process state delivered through the PreparedLayout path.

Note that this change relies on facebook/react#35780 to avoid warnings from React

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D92928315
NickGerleman added a commit to NickGerleman/react-native that referenced this pull request Feb 14, 2026
…cebook#55552)

Summary:
Pull Request resolved: facebook#55552

enablePreparedTextLayout replaces ReactTextView (a real TextView) with PreparedLayoutTextView (a ViewGroup that draws a pre-computed Layout). PreparedLayoutTextView does not support native text selection, so selectable text was broken when the flag was on (T222052152).

This diff adds support for selectable text by routing it through ReactTextView when enablePreparedTextLayout is enabled. A new JS component NativeSelectableText resolves to native name RCTSelectableText when the flag is on, or falls back to RCTText when it is off. Text.js uses NativeSelectableText whenever text is selectable, and a new SelectableTextViewManager (which extends ReactTextViewManager) is registered as RCTSelectableText in all ReactPackage sites.

ReactTextViewManager.updateState() is also updated to handle ReferenceStateWrapper holding PreparedLayout, so that it can process state delivered through the PreparedLayout path.

Note that this change relies on facebook/react#35780 to avoid warnings from React

Changelog:
[General][Changed] - Text Can Conditionally Use "RCTSelectableText" Native Component

Reviewed By: mdvacca

Differential Revision: D92928315
NickGerleman added a commit to NickGerleman/react-native that referenced this pull request Feb 14, 2026
…cebook#55552)

Summary:
Pull Request resolved: facebook#55552

enablePreparedTextLayout replaces ReactTextView (a real TextView) with PreparedLayoutTextView (a ViewGroup that draws a pre-computed Layout). PreparedLayoutTextView does not support native text selection, so selectable text was broken when the flag was on (T222052152).

This diff adds support for selectable text by routing it through ReactTextView when enablePreparedTextLayout is enabled. A new JS component NativeSelectableText resolves to native name RCTSelectableText when the flag is on, or falls back to RCTText when it is off. Text.js uses NativeSelectableText whenever text is selectable, and a new SelectableTextViewManager (which extends ReactTextViewManager) is registered as RCTSelectableText in all ReactPackage sites.

ReactTextViewManager.updateState() is also updated to handle ReferenceStateWrapper holding PreparedLayout, so that it can process state delivered through the PreparedLayout path.

Note that this change relies on facebook/react#35780 to avoid warnings from React

Changelog:
[General][Changed] - Text Can Conditionally Use "RCTSelectableText" Native Component

Reviewed By: mdvacca

Differential Revision: D92928315
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants