Commit a157205
Add selection types to TextInput onChange event (facebook#55043)
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: D901232941 parent 162627a commit a157205
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 | | |
| |||
5281 | 5281 | | |
5282 | 5282 | | |
5283 | 5283 | | |
| 5284 | + | |
5284 | 5285 | | |
5285 | 5286 | | |
5286 | 5287 | | |
| |||
6193 | 6194 | | |
6194 | 6195 | | |
6195 | 6196 | | |
6196 | | - | |
| 6197 | + | |
6197 | 6198 | | |
6198 | | - | |
| 6199 | + | |
6199 | 6200 | | |
6200 | 6201 | | |
6201 | 6202 | | |
6202 | 6203 | | |
6203 | 6204 | | |
6204 | | - | |
| 6205 | + | |
6205 | 6206 | | |
6206 | 6207 | | |
6207 | 6208 | | |
| |||
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