-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fabric : Implements selectable prop for <Text> #15473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ndows into text_selectable
…ndows into text_selectable
…t-native-windows into text_selectable
|
Awesome work ! , |
thank you!, for now default color is only supported (windows blue accent color) but will be taken up as soon this is merged(small change !). |
vineethkuttan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
Please create a task to notify the app of selection change (JS). |
|
I remember you talking about SHIFT + click selection. Please create a task for this too to avoid it slipping through the cracks. |
|
[Nit]
reads much nicer than
This is RNW so Windows is implicitly understood. Keep it minimal without data loss. |
|
Please fix formatting issues in What and Changelog sections. |
|
Just pointing out that this change is only about selecting text within a <View style={styles.selectionTestContainer}>
<Text selectable={true} style={styles.sectionTitle}>Text Selection Test</Text>
<Text selectable={true} style={styles.selectableText}>
This text is SELECTABLE. Try clicking and dragging to select it.
</Text>
</View> |
Good point!, this matches iOS and Android. The React Native docs say selectable (ref: https://reactnative.dev/docs/text#selectable ) enables "native copy and paste functionality" - and native text views (UITextView on iOS, TextView on Android) don't support cross-view selection either. Each text view manages its own selection state independently. |
vnext/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp
Outdated
Show resolved
Hide resolved
vnext/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp
Outdated
Show resolved
Hide resolved
vnext/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp
Show resolved
Hide resolved
| bool hasText = !fullText.empty(); | ||
|
|
||
| // Add menu items (1 = Copy, 2 = Select All) | ||
| AppendMenuW(menu, MF_STRING | (hasSelection ? 0 : MF_GRAYED), 1, L"Copy"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These strings would need to be localized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct , I basically looked at textInput component and it has similar localisation issue(ref :
Line 1889 in 5d22b44
| AppendMenuW(menu, MF_STRING | (hasSelection && !isReadOnly ? 0 : MF_GRAYED), 1, L"Cut"); |
I dont see any infra for localization, shall I add it or is it there and I missed it?
vnext/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp
Outdated
Show resolved
Hide resolved
vnext/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp
Outdated
Show resolved
Hide resolved
…t-native-windows into text_selectable
Description
Implements selectable prop for Text component for windows
Includes :
Type of Change
Why
Parity with RN Android/IOS.
Resolves #13112
What
Made upstream changes to fix the issue where the selectable prop wasn’t being passed to native due to a macro conversion problem.
Ref: facebook/react-native#52599
Also updated logic in the Paragraph component view and composition event handler to correctly handle all selection-related scenarios, including text selection, pointer events, copy-to-clipboard, and other related behaviors.
Screenshots
text_selection.mp4
Testing
Tested in playground
Changelog
Should this change be included in the release notes: _indicate yes
Add a brief summary of the change to use in the release notes for the next release.
Adds text Component selection support for Fabric
Microsoft Reviewers: Open in CodeFlow