Skip to content

Conversation

@alanleedev
Copy link
Contributor

Summary:
This change adds selection data to the TextInput.onChange event for both iOS and Android platforms.

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.

React Native's onChange event previously included selection on iOS (Fabric), but this was removed in PR #51051 to unify with Android (which never had it). This change restores and extends this capability to both platforms, better aligning React Native with web standards.

This is also to support pollyfill added in react-strict-dom; facebook/react-strict-dom#435

What Changed

  1. iOS/macOS (C++): Enable selection in onChange event via TextInputEventEmitter
  2. Android (Kotlin): Added selection data to ReactTextChangedEvent

Changelog

[General][Added] - TextInput onChange event now includes selection data (cursor location) on iOS and Android

Differential Revision: D90123295

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

alanleedev added a commit to alanleedev/react-native that referenced this pull request Jan 5, 2026
Summary:

This change adds `selection` data to the `TextInput.onChange` event for both iOS and Android platforms.

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. 

React Native's `onChange` event previously included `selection` on iOS (Fabric), but this was removed in PR [facebook#51051](facebook#51051) to unify with Android (which never had it). This change restores and extends this capability to both platforms, better aligning React Native with web standards.

This is also to support pollyfill added in `react-strict-dom`; facebook/react-strict-dom#435


## What Changed

1. **iOS/macOS (C++)**: Enable selection in `onChange` event via `TextInputEventEmitter`
2. **Android (Kotlin)**: Added selection data to `ReactTextChangedEvent`

Changelog:
[General][Added] - TextInput onChange event now includes selection data (cursor location) on iOS and Android

Differential Revision: D90123295
alanleedev added a commit to alanleedev/react-native that referenced this pull request Jan 6, 2026
Summary:

This change adds `selection` data to the `TextInput.onChange` event for both iOS and Android platforms.

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.

React Native's `onChange` event previously included `selection` on iOS (Fabric), but this was removed in PR [facebook#51051](facebook#51051) to unify with Android (which never had it). This change restores and extends this capability to both platforms, better aligning React Native with web standards.

This is also to support pollyfill added in `react-strict-dom`; facebook/react-strict-dom#435


## What Changed

1. **iOS/macOS (C++)**: Enable selection in `onChange` event via `TextInputEventEmitter`
2. **Android (Kotlin)**: Added selection data to `ReactTextChangedEvent`

Changelog:
[General][Added] - TextInput onChange event now includes selection data (cursor location) on iOS and Android

Reviewed By: cipolleschi, javache

Differential Revision: D90123295
Summary:

This change adds `selection` data to the `TextInput.onChange` event for both iOS and Android platforms.

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.

React Native's `onChange` event previously included `selection` on iOS (Fabric), but this was removed in PR [facebook#51051](facebook#51051) to unify with Android (which never had it). This change restores and extends this capability to both platforms, better aligning React Native with web standards.

This is also to support pollyfill added in `react-strict-dom`; facebook/react-strict-dom#435


## What Changed

1. **iOS/macOS (C++)**: Enable selection in `onChange` event via `TextInputEventEmitter`
2. **Android (Kotlin)**: Added selection data to `ReactTextChangedEvent`

Changelog:
[General][Added] - TextInput onChange event now includes selection data (cursor location) on iOS and Android

Reviewed By: cipolleschi, javache

Differential Revision: D90123295
@meta-codesync meta-codesync bot closed this in 162627a Jan 6, 2026
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jan 6, 2026
@meta-codesync
Copy link

meta-codesync bot commented Jan 6, 2026

This pull request has been merged in 162627a.

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.

2 participants