Skip to content

Add selection to TextInputChangeEventData in TypeScript types#57249

Open
nsbarsukov wants to merge 1 commit into
react:mainfrom
nsbarsukov:add-selection-to-textinput-change-event-dts
Open

Add selection to TextInputChangeEventData in TypeScript types#57249
nsbarsukov wants to merge 1 commit into
react:mainfrom
nsbarsukov:add-selection-to-textinput-change-event-dts

Conversation

@nsbarsukov

Copy link
Copy Markdown

Summary:

The native TextInput.onChange event now emits selection data (cursor location) on both iOS and Android, added in 162627a (#55044).

The JS companion PR c1f5445 (#55043) added the corresponding types, but only to two of the three TypeScript/Flow type sources:

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

Test Plan:

Type-only change. selection is now available and correctly typed on the onChange event:

<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);
  }}
/>

The native onChange event was updated to emit selection data (162627a)
and the JS companion (c1f5445) added the corresponding types to the Flow
source (TextInput.flow.js) and the generated ReactNativeApi.d.ts, but it
missed the legacy hand-written TextInput.d.ts. This adds the optional
selection field there so all three type sources agree.
@meta-cla

meta-cla Bot commented Jun 17, 2026

Copy link
Copy Markdown

Hi @nsbarsukov!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Jun 17, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@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 Jun 17, 2026
@meta-cla

meta-cla Bot commented Jun 17, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jun 17, 2026
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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant