Commit c1f5445
Add selection types to TextInput onChange event (#55043)
Summary:
Pull Request resolved: #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: 5b575b5c14d23ee53cb0de74b2703673af82513b1 parent fbe6a68 commit c1f5445
File tree
3 files changed
+14
-5
lines changed- packages
- react-native
- Libraries/Components/TextInput
- rn-tester/js/examples/TextInput
3 files changed
+14
-5
lines changedLines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
5304 | 5304 | | |
5305 | 5305 | | |
5306 | 5306 | | |
| 5307 | + | |
5307 | 5308 | | |
5308 | 5309 | | |
5309 | 5310 | | |
| |||
6218 | 6219 | | |
6219 | 6220 | | |
6220 | 6221 | | |
6221 | | - | |
| 6222 | + | |
6222 | 6223 | | |
6223 | | - | |
| 6224 | + | |
6224 | 6225 | | |
6225 | 6226 | | |
6226 | 6227 | | |
6227 | 6228 | | |
6228 | 6229 | | |
6229 | | - | |
| 6230 | + | |
6230 | 6231 | | |
6231 | 6232 | | |
6232 | 6233 | | |
| |||
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
396 | | - | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
397 | 404 | | |
398 | 405 | | |
399 | 406 | | |
| |||
0 commit comments