Skip to content

Add selection types to TextInput onChange event#55043

Closed
alanleedev wants to merge 1 commit into
react:mainfrom
alanleedev:export-D90123294
Closed

Add selection types to TextInput onChange event#55043
alanleedev wants to merge 1 commit into
react:mainfrom
alanleedev:export-D90123294

Conversation

@alanleedev

@alanleedev alanleedev commented Jan 5, 2026

Copy link
Copy Markdown
Contributor

Summary:
This change adds TypeScript/Flow types and RNTester examples for the selection data in TextInput.onChange event.

This is the JS companion to the native changes that add selection data to the onChange event.

Why

On the web, text input elements provide selectionStart and selectionEnd properties that are always accessible during input events. This change exposes the selection data that native now provides, allowing developers to access cursor position during onChange.

What Changed

  1. Flow Types: Added optional selection?: Selection to TextInputChangeEventData
  2. TypeScript Types: Updated ReactNativeApi.d.ts with selection type
  3. RNTester: Updated examples to display selection in event logs

Changelog

[General][Added] - TextInput onChange event types now include optional selection data

Differential Revision: D90123294

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 5, 2026
@meta-codesync

meta-codesync Bot commented Jan 5, 2026

Copy link
Copy Markdown

@alanleedev has exported this pull request. If you are a Meta employee, you can view the originating Diff in D90123294.

Summary:

This change adds TypeScript/Flow types and RNTester examples for the `selection` data in `TextInput.onChange` event.

This is the JS companion to the native changes that add selection data to the onChange event. 

NOTE:selection only represents the cursor location when returned via onChange as this will not be invoked on a pure selection change without text change. We should also add this note to the documentation.

## Why

On the web, text input elements provide `selectionStart` and `selectionEnd` properties that are always accessible during input events. This change exposes the selection data that native now provides, allowing developers to access cursor position during onChange.

## What Changed

1. **Flow Types**: Added optional `selection?: Selection` to `TextInputChangeEventData`
2. **TypeScript Types**: Updated `ReactNativeApi.d.ts` with selection type
3. **RNTester**: Updated examples to display selection in event logs

Changelog:
[General][Added] - TextInput onChange event types now include optional selection data

Reviewed By: cipolleschi, necolas

Differential Revision: D90123294
@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @alanleedev in c1f5445

When will my fix make it into a release? | How to file a pick request?

@react-native-bot react-native-bot added the Merged This PR has been merged. label Jan 20, 2026
@meta-codesync

meta-codesync Bot commented Jan 20, 2026

Copy link
Copy Markdown

This pull request has been merged in c1f5445.

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants