A framework for building native applications using React
Add selection types to TextInput onChange event (#55043)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55043 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 fbshipit-source-id: 5b575b5c14d23ee53cb0de74b2703673af82513b
A
Alan Lee committed
c1f5445f4a59d0035389725e47da58eb3d2c267c
Parent: fbe6a68
Committed by meta-codesync[bot] <215208954+meta-codesync[bot]@users.noreply.github.com>
on 1/20/2026, 11:30:41 PM