Commit e745c41
Summary:
The native `TextInput.onChange` event now emits `selection` data (cursor location) on both iOS and Android, added in [162627a](162627a) (#55044).
- #55044
The JS companion PR [c1f5445](c1f5445) (#55043) added the corresponding types, but only to two of the three TypeScript/Flow type sources:
- #55043
| Type source | Has `selection`? |
|---|---|
| `TextInput.flow.js` (Flow) | ✅ |
| `ReactNativeApi.d.ts` (generated API surface) | ✅ |
| `TextInput.d.ts` (legacy public `.d.ts`) | ❌ |
The hand-written legacy `TextInput.d.ts` was missed, so consumers relying on it can't access `selection` from the `onChange` event even though native genuinely sends it. This PR adds the optional `selection` field there so all three type sources agree.
## Changelog:
[GENERAL] [ADDED] - Add `selection` to `TextInputChangeEventData` in TypeScript types
Pull Request resolved: #57249
Test Plan:
Type-only change. `selection` is now available and correctly typed on the `onChange` event:
```tsx
<TextInput
onChange={e => {
// e.nativeEvent.selection is now typed as { start: number; end: number } | undefined
console.log(e.nativeEvent.selection?.start, e.nativeEvent.selection?.end);
}}
/>
Reviewed By: christophpurrer
Differential Revision: D109435915
Pulled By: fabriziocucci
fbshipit-source-id: b334e52e0e39a7f9053bf41e93077be90b3d9adf
1 parent 5c197fb commit e745c41
1 file changed
Lines changed: 6 additions & 0 deletions
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
518 | 524 | | |
519 | 525 | | |
520 | 526 | | |
| |||
0 commit comments