Skip to content

Conversation

@alanleedev
Copy link
Contributor

@alanleedev alanleedev commented Jan 5, 2026

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

meta-codesync bot commented Jan 5, 2026

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

alanleedev added a commit to alanleedev/react-native that referenced this pull request Jan 5, 2026
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
alanleedev added a commit to alanleedev/react-native that referenced this pull request Jan 5, 2026
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

Differential Revision: 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
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 meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants