From ab373989c3fc8cf5f7b769a9b607de924cc41e28 Mon Sep 17 00:00:00 2001 From: Mathieu Acthernoene Date: Thu, 24 Sep 2026 10:42:22 -0700 Subject: [PATCH] Remove TextInput blurOnSubmit (#57393) Summary: Removes the `blurOnSubmit` TextInput prop, deprecated since 0.77 in favor of `submitBehavior`. Cleans it from the JS API, types, native component spec, and rn-tester examples. Default behavior is unchanged: single-line inputs blur and submit, multiline inputs insert a newline. See https://github.com/react/react-native/issues/57384 ## Changelog: [GENERAL] [REMOVED] - Remove deprecated `TextInput` `blurOnSubmit` prop (use `submitBehavior` instead) Pull Request resolved: https://github.com/react/react-native/pull/57393 Test Plan: - `yarn flow check` passes - `yarn build-types` regenerates the API snapshot without `blurOnSubmit` - rn-tester "Submit behavior" example still covers all `submitBehavior` values Reviewed By: andrewdacenko Differential Revision: D110336776 Pulled By: Abbondanzo fbshipit-source-id: 214e6270e8cab04b87f7a90972c6be5174cacc40 --- .../AndroidTextInputNativeComponent.js | 14 --- .../Components/TextInput/TextInput.flow.js | 14 --- .../Components/TextInput/TextInput.js | 12 +- .../TextInput/RCTTextInputComponentView.mm | 2 +- packages/react-native/ReactNativeApi.d.ts | 7 +- .../Components/TextInput/TextInput.d.ts | 14 --- .../TextInput/TextInputExample.ios.js | 20 ---- .../TextInput/TextInputSharedExamples.js | 105 ++---------------- 8 files changed, 13 insertions(+), 175 deletions(-) diff --git a/packages/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js b/packages/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js index 37f4fa6768c..fd8fd9919d6 100644 --- a/packages/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +++ b/packages/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js @@ -533,20 +533,6 @@ export type AndroidTextInputNativeProps = Readonly<{ */ selectTextOnFocus?: ?boolean, - /** - * If `true`, the text field will blur when submitted. - * The default value is true for single-line fields and false for - * multiline fields. Note that for multiline fields, setting `blurOnSubmit` - * to `true` means that pressing return will blur the field and trigger the - * `onSubmitEditing` event instead of inserting a newline into the field. - * - * @deprecated - * Note that `submitBehavior` now takes the place of `blurOnSubmit` and will - * override any behavior defined by `blurOnSubmit`. - * @see submitBehavior - */ - blurOnSubmit?: ?boolean, - /** * When the return key is pressed, * diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js b/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js index eaf81c88d84..91bc7901343 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js @@ -965,20 +965,6 @@ type TextInputBaseProps = Readonly<{ */ selectTextOnFocus?: ?boolean, - /** - * If `true`, the text field will blur when submitted. - * The default value is true for single-line fields and false for - * multiline fields. Note that for multiline fields, setting `blurOnSubmit` - * to `true` means that pressing return will blur the field and trigger the - * `onSubmitEditing` event instead of inserting a newline into the field. - * - * @deprecated - * Note that `submitBehavior` now takes the place of `blurOnSubmit` and will - * override any behavior defined by `blurOnSubmit`. - * @see submitBehavior - */ - blurOnSubmit?: ?boolean, - /** * When the return key is pressed, * diff --git a/packages/react-native/Libraries/Components/TextInput/TextInput.js b/packages/react-native/Libraries/Components/TextInput/TextInput.js index ee48b398c12..f54356b1a8d 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.js +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.js @@ -456,18 +456,10 @@ function InternalTextInput(props: TextInputProps): React.Node { submitBehavior = props.submitBehavior; } } else if (multiline) { - if (props.blurOnSubmit === true) { - submitBehavior = 'blurAndSubmit'; - } else { - submitBehavior = 'newline'; - } + submitBehavior = 'newline'; } else { // Single line - if (props.blurOnSubmit !== false) { - submitBehavior = 'blurAndSubmit'; - } else { - submitBehavior = 'submit'; - } + submitBehavior = 'blurAndSubmit'; } const accessible = props.accessible !== false; 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 8f55121cd23..34dfa8f1c5f 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -289,7 +289,7 @@ static NSSet *returnKeyTypesSet; [self _setShowSoftInputOnFocus:newTextInputProps.traits.showSoftInputOnFocus]; } - // Traits `blurOnSubmit`, `clearTextOnFocus`, and `selectTextOnFocus` were omitted intentionally here + // Traits `clearTextOnFocus` and `selectTextOnFocus` were omitted intentionally here // because they are being checked on-demand. // Other props: diff --git a/packages/react-native/ReactNativeApi.d.ts b/packages/react-native/ReactNativeApi.d.ts index adf9f38d701..9cbf80b9293 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<<2e80ab7a8c4c5de55dc0f7cd7a7be0ed>> + * @generated SignedSource<> * * This file was generated by scripts/js-api/build-types/index.js. */ @@ -5013,7 +5013,6 @@ declare type TextInputBaseProps = { | "wifi-password" readonly autoCorrect?: boolean readonly autoFocus?: boolean - readonly blurOnSubmit?: boolean readonly caretHidden?: boolean readonly contextMenuHidden?: boolean readonly defaultValue?: string @@ -6006,7 +6005,7 @@ export { TaskProvider, // 266dedf2 Text, // d023b11d TextContentType, // 239b3ecc - TextInput, // 0aec86ba + TextInput, // b7d29fe7 TextInputAndroidProps, // 9ebbc103 TextInputBlurEvent, // b4c7a58c TextInputChangeEvent, // 92363e10 @@ -6016,7 +6015,7 @@ export { TextInputIOSProps, // fb3c9327 TextInputInstance, // 53fe7b73 TextInputKeyPressEvent, // cbbc322a - TextInputProps, // 88ef6be8 + TextInputProps, // 21d5b23c TextInputSelectionChangeEvent, // 4a8f10c2 TextInputSubmitEditingEvent, // e811fdbd TextInstance, // 7c7e2069 diff --git a/packages/react-native/types_DEPRECATED/Libraries/Components/TextInput/TextInput.d.ts b/packages/react-native/types_DEPRECATED/Libraries/Components/TextInput/TextInput.d.ts index 21bb5c60658..b3ed1412424 100644 --- a/packages/react-native/types_DEPRECATED/Libraries/Components/TextInput/TextInput.d.ts +++ b/packages/react-native/types_DEPRECATED/Libraries/Components/TextInput/TextInput.d.ts @@ -726,20 +726,6 @@ export interface TextInputProps */ autoFocus?: boolean | undefined; - /** - * If `true`, the text field will blur when submitted. - * The default value is true for single-line fields and false for - * multiline fields. Note that for multiline fields, setting `blurOnSubmit` - * to `true` means that pressing return will blur the field and trigger the - * `onSubmitEditing` event instead of inserting a newline into the field. - * - * @deprecated - * Note that `submitBehavior` now takes the place of `blurOnSubmit` and will - * override any behavior defined by `blurOnSubmit`. - * @see submitBehavior - */ - blurOnSubmit?: boolean | undefined; - /** * When the return key is pressed, * diff --git a/packages/rn-tester/js/examples/TextInput/TextInputExample.ios.js b/packages/rn-tester/js/examples/TextInput/TextInputExample.ios.js index a3e0621e8bf..a6bcda4ec18 100644 --- a/packages/rn-tester/js/examples/TextInput/TextInputExample.ios.js +++ b/packages/rn-tester/js/examples/TextInput/TextInputExample.ios.js @@ -22,7 +22,6 @@ import TextInputSharedExamples from './TextInputSharedExamples'; import * as React from 'react'; import {useRef} from 'react'; import { - Alert, Button, InputAccessoryView, StyleSheet, @@ -575,25 +574,6 @@ const textInputExamples: Array = [ ); }, }, - { - title: 'Multiline blur on submit', - render: function (): React.Node { - return ( - - - Alert.alert('Alert', event.nativeEvent.text) - } - /> - - ); - }, - }, { title: 'Multiline', render: function (): React.Node { diff --git a/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js b/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js index 85c16b0a583..fd9e8f1c1b0 100644 --- a/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js +++ b/packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js @@ -212,62 +212,6 @@ class RewriteInvalidCharactersAndClearExample extends React.Component< type ExampleRef = {current: null | React.ElementRef}; -class BlurOnSubmitExample extends React.Component<{...}> { - ref1: ExampleRef = createRef(); - ref2: ExampleRef = createRef(); - ref3: ExampleRef = createRef(); - ref4: ExampleRef = createRef(); - ref5: ExampleRef = createRef(); - - render(): React.Node { - return ( - - this.ref2.current?.focus()} - /> - this.ref3.current?.focus()} - /> - this.ref4.current?.focus()} - /> - this.ref5.current?.focus()} - /> - - - ); - } -} - class SubmitBehaviorExample extends React.Component<{...}> { ref1: ExampleRef = createRef(); ref2: ExampleRef = createRef(); @@ -276,10 +220,6 @@ class SubmitBehaviorExample extends React.Component<{...}> { ref5: ExampleRef = createRef(); ref6: ExampleRef = createRef(); ref7: ExampleRef = createRef(); - ref8: ExampleRef = createRef(); - ref9: ExampleRef = createRef(); - ref10: ExampleRef = createRef(); - ref11: ExampleRef = createRef(); render(): React.Node { return ( @@ -303,51 +243,26 @@ class SubmitBehaviorExample extends React.Component<{...}> { /> this.ref5.current?.focus()} /> this.ref6.current?.focus()} /> this.ref7.current?.focus()} - /> - this.ref8.current?.focus()} - /> - this.ref9.current?.focus()} - /> - - @@ -1049,12 +964,6 @@ module.exports = [ return {examples}; }, }, - { - title: 'Blur on submit', - render: function (): React.MixedElement { - return ; - }, - }, { title: 'enterKeyHint modes', name: 'enterKeyHintTypes',