diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts b/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts index 75837e341711a7..61dc4ac0370d51 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts @@ -17,6 +17,8 @@ import { import {ColorValue, StyleProp} from '../../StyleSheet/StyleSheet'; import {TextStyle} from '../../StyleSheet/StyleSheetTypes'; import { + NativeBlurEvent, + NativeFocusEvent, NativeSyntheticEvent, NativeTouchEvent, TargetedEvent, @@ -426,10 +428,18 @@ export interface TextInputAndroidProps { verticalAlign?: 'auto' | 'top' | 'bottom' | 'middle' | undefined; } +/** + * @see TextInputProps.onBlur + */ +export interface TextInputBlurEventData extends NativeBlurEvent { + text: string; + eventCount: number; +} + /** * @see TextInputProps.onFocus */ -export interface TextInputFocusEventData extends TargetedEvent { +export interface TextInputFocusEventData extends NativeFocusEvent { text: string; eventCount: number; } @@ -736,7 +746,7 @@ export interface TextInputProps * Callback that is called when the text input is blurred */ onBlur?: - | ((e: NativeSyntheticEvent) => void) + | ((e: NativeSyntheticEvent) => void) | undefined; /** diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.js b/packages/react-native/Libraries/Components/TextInput/TextInput.js index b60ae10fa8abcf..0e44cb4b2163e1 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.js +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.js @@ -10,6 +10,8 @@ import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes'; import type { + BlurEvent, + FocusEvent, PressEvent, ScrollEvent, SyntheticEvent, @@ -96,15 +98,6 @@ export type ContentSizeChangeEvent = SyntheticEvent< |}>, >; -type TargetEvent = SyntheticEvent< - $ReadOnly<{| - target: number, - |}>, ->; - -export type BlurEvent = TargetEvent; -export type FocusEvent = TargetEvent; - type Selection = $ReadOnly<{| start: number, end: number, diff --git a/packages/react-native/Libraries/Types/CoreEventTypes.js b/packages/react-native/Libraries/Types/CoreEventTypes.js index a0234e95f26d16..991681858cbbdb 100644 --- a/packages/react-native/Libraries/Types/CoreEventTypes.js +++ b/packages/react-native/Libraries/Types/CoreEventTypes.js @@ -270,17 +270,14 @@ export type ScrollEvent = SyntheticEvent< |}>, >; -export type BlurEvent = SyntheticEvent< +type TargetEvent = SyntheticEvent< $ReadOnly<{| target: number, |}>, >; -export type FocusEvent = SyntheticEvent< - $ReadOnly<{| - target: number, - |}>, ->; +export type BlurEvent = TargetEvent; +export type FocusEvent = TargetEvent; export type MouseEvent = SyntheticEvent< $ReadOnly<{|