diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js b/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js index 8438a0eac100c1..5b3d3dbdf7f0ab 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js @@ -29,6 +29,7 @@ type TextInputChangeEventData = $ReadOnly<{ eventCount: number, target: number, text: string, + selection?: Selection, }>; export type TextInputChangeEvent = diff --git a/packages/react-native/ReactNativeApi.d.ts b/packages/react-native/ReactNativeApi.d.ts index be0534addca38f..81372938c36170 100644 --- a/packages/react-native/ReactNativeApi.d.ts +++ b/packages/react-native/ReactNativeApi.d.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<9504863966549f8efbbe4e13d7f74eaf>> + * @generated SignedSource<<99e87935a1173976a04d45d4e55bfa89>> * * This file was generated by scripts/js-api/build-types/index.js. */ @@ -5281,6 +5281,7 @@ declare type TextInputChangeEvent = NativeSyntheticEvent declare type TextInputChangeEventData = { readonly eventCount: number + readonly selection?: Selection readonly target: number readonly text: string } @@ -6193,15 +6194,15 @@ export { TaskProvider, // 266dedf2 Text, // e55ac2e2 TextContentType, // 239b3ecc - TextInput, // cf7a3331 + TextInput, // 2e89b91d TextInputAndroidProps, // 3f09ce49 - TextInputChangeEvent, // 380cbe93 + TextInputChangeEvent, // 6821f629 TextInputContentSizeChangeEvent, // 5fba3f54 TextInputEndEditingEvent, // 8c22fac3 TextInputFocusEvent, // c36e977c TextInputIOSProps, // 0d05a855 TextInputKeyPressEvent, // 967178c2 - TextInputProps, // a817a7f7 + TextInputProps, // c75f0362 TextInputSelectionChangeEvent, // a1a7622f TextInputSubmitEditingEvent, // 48d903af TextLayoutEvent, // 45b0a8d7 diff --git a/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js b/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js index 2de5275b9dd290..2e789412f981ef 100644 --- a/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js +++ b/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js @@ -393,7 +393,14 @@ class TextEventsExample extends React.Component<{...}, $FlowFixMe> { onFocus={() => this.updateText('onFocus')} onBlur={() => this.updateText('onBlur')} onChange={event => - this.updateText('onChange text: ' + event.nativeEvent.text) + this.updateText( + 'onChange text: ' + + event.nativeEvent.text + + ', selection: ' + + (event.nativeEvent.selection != null + ? JSON.stringify(event.nativeEvent.selection) + : 'undefined'), + ) } onContentSizeChange={event => this.updateText(