Skip to content

Conversation

@iamAbhi-916
Copy link
Contributor

@iamAbhi-916 iamAbhi-916 commented Dec 11, 2025

Description

Implements selectable prop for Text component for windows

Includes :

  • Basic text selection - Click and drag to select
  • Selection highlight - default windows blue accent background on selected text
  • Ctrl+C - Copy to clipboard
  • Ctrl+A - Select all text
  • Double-click - Select word
  • Right-click context menu - Copy / Select All options
  • Clear selection on click outside - Deselects when clicking elsewhere
  • Implements I-beam cursor for selectable text
  • Selection continues extending even when cursor is outside the selection range

Type of Change

  • New feature (non-breaking change which adds functionality)

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

@iamAbhi-916 iamAbhi-916 changed the title Fabric : Implements selectable prop for Text component for windows Fabric : Implements selectable prop for text component for windows Dec 11, 2025
@vineethkuttan
Copy link
Contributor

Awesome work ! ,
Is the SelectionHighlightColor customizable through JavaScript?

@iamAbhi-916 iamAbhi-916 marked this pull request as ready for review December 12, 2025 05:29
@iamAbhi-916 iamAbhi-916 requested a review from a team as a code owner December 12, 2025 05:29
@iamAbhi-916
Copy link
Contributor Author

Awesome work ! , Is the SelectionHighlightColor customizable through JavaScript?

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 !).

Copy link
Contributor

@vineethkuttan vineethkuttan left a comment

Choose a reason for hiding this comment

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

LGTM!

@sundaramramaswamy
Copy link
Contributor

Please create a task to notify the app of selection change (JS).

@sundaramramaswamy
Copy link
Contributor

sundaramramaswamy commented Dec 12, 2025

I remember you talking about SHIFT + click selection. Please create a task for this too to avoid it slipping through the cracks.

@sundaramramaswamy
Copy link
Contributor

sundaramramaswamy commented Dec 12, 2025

Resolves [Add Relevant Issue Here]
#13112

Resolves #13112.

Drop template strings; they're noise in the actual PR message.

@sundaramramaswamy
Copy link
Contributor

sundaramramaswamy commented Dec 12, 2025

[Nit]

Implement selectable prop for <Text>

reads much nicer than

Implements selectable prop for Text component for windows

This is RNW so Windows is implicitly understood. Keep it minimal without data loss.

@sundaramramaswamy
Copy link
Contributor

sundaramramaswamy commented Dec 12, 2025

Please fix formatting issues in What and Changelog sections.

@iamAbhi-916 iamAbhi-916 changed the title Fabric : Implements selectable prop for text component for windows Fabric : Implements selectable prop for <Text> Dec 12, 2025
@sundaramramaswamy
Copy link
Contributor

sundaramramaswamy commented Dec 12, 2025

Just pointing out that this change is only about selecting text within a <Text> component and the user won't be able to select text spanning across two components, even if they're both selectable.

<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>

@iamAbhi-916
Copy link
Contributor Author

iamAbhi-916 commented Dec 12, 2025

I know this may be beyond the scope of this PR but just pointing it out that this change is only about selecting text within a <Text> component and the user won't be able to select text spanning across two components.

<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.

bool hasText = !fullText.empty();

// Add menu items (1 = Copy, 2 = Select All)
AppendMenuW(menu, MF_STRING | (hasSelection ? 0 : MF_GRAYED), 1, L"Copy");
Copy link
Contributor

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.

Copy link
Contributor Author

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 :

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?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement selectable property for Text for fabric

4 participants