diff --git a/packages/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js b/packages/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js index f91026796ce9..2875ebb776d4 100644 --- a/packages/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js +++ b/packages/react-native/Libraries/Components/TextInput/RCTTextInputViewConfig.js @@ -79,18 +79,12 @@ const RCTTextInputViewConfig = { topTextInput: { registrationName: 'onTextInput', }, - topKeyPressSync: { - registrationName: 'onKeyPressSync', - }, topScroll: { registrationName: 'onScroll', }, topSelectionChange: { registrationName: 'onSelectionChange', }, - topChangeSync: { - registrationName: 'onChangeSync', - }, topContentSizeChange: { registrationName: 'onContentSizeChange', }, @@ -159,8 +153,6 @@ const RCTTextInputViewConfig = { onSelectionChange: true, onContentSizeChange: true, onScroll: true, - onChangeSync: true, - onKeyPressSync: true, onTextInput: true, }), }, diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.js b/packages/react-native/Libraries/Components/TextInput/TextInput.js index c8ead59c1192..7034e6b6320f 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.js +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.js @@ -741,33 +741,12 @@ export type Props = $ReadOnly<{| */ onChange?: ?(e: ChangeEvent) => mixed, - /** - * DANGER: this API is not stable and will change in the future. - * - * Callback will be called on the main thread and may result in dropped frames. - * Callback that is called when the text input's text changes. - * - * @platform ios - */ - unstable_onChangeSync?: ?(e: ChangeEvent) => mixed, - /** * Callback that is called when the text input's text changes. * Changed text is passed as an argument to the callback handler. */ onChangeText?: ?(text: string) => mixed, - /** - * DANGER: this API is not stable and will change in the future. - * - * Callback will be called on the main thread and may result in dropped frames. - * Callback that is called when the text input's text changes. - * Changed text is passed as an argument to the callback handler. - * - * @platform ios - */ - unstable_onChangeTextSync?: ?(text: string) => mixed, - /** * Callback that is called when the text input's content size changes. * This will be called with @@ -796,21 +775,6 @@ export type Props = $ReadOnly<{| */ onKeyPress?: ?(e: KeyPressEvent) => mixed, - /** - * DANGER: this API is not stable and will change in the future. - * - * Callback will be called on the main thread and may result in dropped frames. - * - * Callback that is called when a key is pressed. - * This will be called with `{ nativeEvent: { key: keyValue } }` - * where `keyValue` is `'Enter'` or `'Backspace'` for respective keys and - * the typed-in character otherwise including `' '` for space. - * Fires before `onChange` callbacks. - * - * @platform ios - */ - unstable_onKeyPressSync?: ?(e: KeyPressEvent) => mixed, - /** * Called when a single tap gesture is detected. */ @@ -1308,26 +1272,6 @@ function InternalTextInput(props: Props): React.Node { setMostRecentEventCount(event.nativeEvent.eventCount); }; - const _onChangeSync = (event: ChangeEvent) => { - const currentText = event.nativeEvent.text; - props.unstable_onChangeSync && props.unstable_onChangeSync(event); - props.unstable_onChangeTextSync && - props.unstable_onChangeTextSync(currentText); - - if (inputRef.current == null) { - // calling `props.onChange` or `props.onChangeText` - // may clean up the input itself. Exits here. - return; - } - - setLastNativeText(currentText); - // This must happen last, after we call setLastNativeText. - // Different ordering can cause bugs when editing AndroidTextInputs - // with multiple Fragments. - // We must update this so that controlled input updates work. - setMostRecentEventCount(event.nativeEvent.eventCount); - }; - const _onSelectionChange = (event: SelectionChangeEvent) => { props.onSelectionChange && props.onSelectionChange(event); @@ -1470,10 +1414,6 @@ function InternalTextInput(props: Props): React.Node { style.paddingVertical == null && style.paddingTop == null)); - const useOnChangeSync = - (props.unstable_onChangeSync || props.unstable_onChangeTextSync) && - !(props.onChange || props.onChangeText); - textInput = ( { input = renderTree.root.findByType(TextInput); }); it('has expected instance functions', () => { - expect(inputRef.current.isFocused).toBeInstanceOf(Function); // Would have prevented S168585 + expect(inputRef.current.isFocused).toBeInstanceOf(Function); // Would have prevented S168585 expect(inputRef.current.clear).toBeInstanceOf(Function); expect(inputRef.current.focus).toBeInstanceOf(jest.fn().constructor); expect(inputRef.current.blur).toBeInstanceOf(jest.fn().constructor); @@ -89,7 +78,6 @@ describe('TextInput tests', () => { it('focus() should not do anything if the TextInput is not editable', () => { const textInputRef = createTextInput({editable: false}); - // currentProps is the property actually containing props at runtime textInputRef.current.currentProps = textInputRef.current.props; expect(textInputRef.current.isFocused()).toBe(false); @@ -183,7 +171,6 @@ describe('TextInput tests', () => { mostRecentEventCount={0} onBlur={[Function]} onChange={[Function]} - onChangeSync={null} onClick={[Function]} onFocus={[Function]} onResponderGrant={[Function]} @@ -229,7 +216,6 @@ describe('TextInput', () => { mostRecentEventCount={0} onBlur={[Function]} onChange={[Function]} - onChangeSync={null} onClick={[Function]} onFocus={[Function]} onResponderGrant={[Function]} @@ -275,7 +261,6 @@ describe('TextInput compat with web', () => { nativeID="id" onBlur={[Function]} onChange={[Function]} - onChangeSync={null} onClick={[Function]} onFocus={[Function]} onResponderGrant={[Function]} @@ -407,7 +392,6 @@ describe('TextInput compat with web', () => { mostRecentEventCount={0} onBlur={[Function]} onChange={[Function]} - onChangeSync={null} onClick={[Function]} onFocus={[Function]} onResponderGrant={[Function]} @@ -450,7 +434,6 @@ describe('TextInput compat with web', () => { mostRecentEventCount={0} onBlur={[Function]} onChange={[Function]} - onChangeSync={null} onClick={[Function]} onFocus={[Function]} onResponderGrant={[Function]} diff --git a/packages/react-native/Libraries/Components/TextInput/__tests__/__snapshots__/TextInput-test.js.snap b/packages/react-native/Libraries/Components/TextInput/__tests__/__snapshots__/TextInput-test.js.snap index ac93dc2e644c..4c9b1e93b71a 100644 --- a/packages/react-native/Libraries/Components/TextInput/__tests__/__snapshots__/TextInput-test.js.snap +++ b/packages/react-native/Libraries/Components/TextInput/__tests__/__snapshots__/TextInput-test.js.snap @@ -9,7 +9,6 @@ exports[`TextInput tests should render as expected: should deep render when mock mostRecentEventCount={0} onBlur={[Function]} onChange={[Function]} - onChangeSync={null} onClick={[Function]} onFocus={[Function]} onResponderGrant={[Function]} @@ -38,7 +37,6 @@ exports[`TextInput tests should render as expected: should deep render when not mostRecentEventCount={0} onBlur={[Function]} onChange={[Function]} - onChangeSync={null} onClick={[Function]} onFocus={[Function]} onResponderGrant={[Function]} diff --git a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap index 6b62f086b1dd..ab7be2f1001e 100644 --- a/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap +++ b/packages/react-native/Libraries/__tests__/__snapshots__/public-api-test.js.snap @@ -3041,14 +3041,11 @@ export type Props = $ReadOnly<{| multiline?: ?boolean, onBlur?: ?(e: BlurEvent) => mixed, onChange?: ?(e: ChangeEvent) => mixed, - unstable_onChangeSync?: ?(e: ChangeEvent) => mixed, onChangeText?: ?(text: string) => mixed, - unstable_onChangeTextSync?: ?(text: string) => mixed, onContentSizeChange?: ?(e: ContentSizeChangeEvent) => mixed, onEndEditing?: ?(e: EditingEvent) => mixed, onFocus?: ?(e: FocusEvent) => mixed, onKeyPress?: ?(e: KeyPressEvent) => mixed, - unstable_onKeyPressSync?: ?(e: KeyPressEvent) => mixed, onPress?: ?(event: PressEvent) => mixed, onPressIn?: ?(event: PressEvent) => mixed, onPressOut?: ?(event: PressEvent) => mixed, diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm index 44e74da5cea0..7c50d3f81a3e 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -341,11 +341,7 @@ - (NSString *)textInputShouldChangeText:(NSString *)text inRange:(NSRange)range keyPressMetrics.eventCount = _mostRecentEventCount; const auto &textInputEventEmitter = static_cast(*_eventEmitter); - if (props.onKeyPressSync) { - textInputEventEmitter.onKeyPressSync(keyPressMetrics); - } else { - textInputEventEmitter.onKeyPress(keyPressMetrics); - } + textInputEventEmitter.onKeyPress(keyPressMetrics); } } @@ -391,12 +387,7 @@ - (void)textInputDidChange if (_eventEmitter) { const auto &textInputEventEmitter = static_cast(*_eventEmitter); - const auto &props = static_cast(*_props); - if (props.onChangeSync) { - textInputEventEmitter.onChangeSync([self _textInputMetrics]); - } else { - textInputEventEmitter.onChange([self _textInputMetrics]); - } + textInputEventEmitter.onChange([self _textInputMetrics]); } } diff --git a/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.cpp b/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.cpp index 88ae3f35a221..8f1bf5734add 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.cpp @@ -91,12 +91,6 @@ void TextInputEventEmitter::onChange( dispatchTextInputEvent("change", textInputMetrics); } -void TextInputEventEmitter::onChangeSync( - const TextInputMetrics& textInputMetrics) const { - dispatchTextInputEvent( - "changeSync", textInputMetrics, EventPriority::SynchronousBatched); -} - void TextInputEventEmitter::onContentSizeChange( const TextInputMetrics& textInputMetrics) const { dispatchTextInputContentSizeChangeEvent( @@ -128,16 +122,6 @@ void TextInputEventEmitter::onKeyPress( EventPriority::AsynchronousBatched); } -void TextInputEventEmitter::onKeyPressSync( - const KeyPressMetrics& keyPressMetrics) const { - dispatchEvent( - "keyPressSync", - [keyPressMetrics](jsi::Runtime& runtime) { - return keyPressMetricsPayload(runtime, keyPressMetrics); - }, - EventPriority::SynchronousBatched); -} - void TextInputEventEmitter::onScroll( const TextInputMetrics& textInputMetrics) const { dispatchTextInputEvent("scroll", textInputMetrics); diff --git a/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.h b/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.h index 0ab2b18544fc..a4c68483c235 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.h +++ b/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/ios/react/renderer/components/iostextinput/TextInputEventEmitter.h @@ -39,13 +39,11 @@ class TextInputEventEmitter : public ViewEventEmitter { void onFocus(const TextInputMetrics& textInputMetrics) const; void onBlur(const TextInputMetrics& textInputMetrics) const; void onChange(const TextInputMetrics& textInputMetrics) const; - void onChangeSync(const TextInputMetrics& textInputMetrics) const; void onContentSizeChange(const TextInputMetrics& textInputMetrics) const; void onSelectionChange(const TextInputMetrics& textInputMetrics) const; void onEndEditing(const TextInputMetrics& textInputMetrics) const; void onSubmitEditing(const TextInputMetrics& textInputMetrics) const; void onKeyPress(const KeyPressMetrics& keyPressMetrics) const; - void onKeyPressSync(const KeyPressMetrics& keyPressMetrics) const; void onScroll(const TextInputMetrics& textInputMetrics) const; private: