From ac45f41d8756ceb44a1a70cf193af82bec62b0ce Mon Sep 17 00:00:00 2001 From: Mathieu Acthernoene Date: Wed, 1 Jul 2026 11:12:15 +0200 Subject: [PATCH] Remove TextInput blurOnSubmit # Conflicts: # packages/react-native/ReactNativeApi.d.ts # Conflicts: # packages/react-native/ReactNativeApi.d.ts # Conflicts: # packages/react-native/ReactNativeApi.d.ts --- .../AndroidTextInputNativeComponent.js | 14 --- .../Components/TextInput/TextInput.d.ts | 14 --- .../Components/TextInput/TextInput.flow.js | 14 --- .../Components/TextInput/TextInput.js | 12 +-- .../TextInput/RCTTextInputComponentView.mm | 2 +- packages/react-native/ReactNativeApi.d.ts | 7 +- .../TextInput/TextInputExample.ios.js | 20 ---- .../TextInput/TextInputSharedExamples.js | 101 +----------------- 8 files changed, 11 insertions(+), 173 deletions(-) diff --git a/packages/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js b/packages/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js index b0cf8dafd2d2..07827d5da231 100644 --- a/packages/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +++ b/packages/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js @@ -530,20 +530,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.d.ts b/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts index 6f24c1d360ba..012b0066cfb3 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts @@ -756,20 +756,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/react-native/Libraries/Components/TextInput/TextInput.flow.js b/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js index a38c30aa751b..b83c314b01c5 100644 --- a/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js +++ b/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js @@ -986,20 +986,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 2854f5e53cc0..45c30872b5f9 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 c0e56acd2a0f..4febecba7da5 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -280,7 +280,7 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & [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 293ae885d55d..4100b24b1582 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<<67eb674c33870c82986054f0cee48385>> + * @generated SignedSource<<2c6adf9c7a53584ccea28297cd69a793>> * * This file was generated by scripts/js-api/build-types/index.js. */ @@ -5129,7 +5129,6 @@ declare type TextInputBaseProps = { | "wifi-password" readonly autoCorrect?: boolean readonly autoFocus?: boolean - readonly blurOnSubmit?: boolean readonly caretHidden?: boolean readonly contextMenuHidden?: boolean readonly defaultValue?: string @@ -6135,7 +6134,7 @@ export { TaskProvider, // 266dedf2 Text, // f792e51d TextContentType, // 239b3ecc - TextInput, // 1c32d882 + TextInput, // 23c86495 TextInputAndroidProps, // 3f09ce49 TextInputBlurEvent, // b77af40e TextInputChangeEvent, // f55eef98 @@ -6145,7 +6144,7 @@ export { TextInputIOSProps, // 0d05a855 TextInputInstance, // 5a0c0e0d TextInputKeyPressEvent, // 546c5d07 - TextInputProps, // 08c36ff7 + TextInputProps, // 2f454a43 TextInputSelectionChangeEvent, // e58f2abc TextInputSubmitEditingEvent, // 6bcb2aa5 TextInstance, // 05463a96 diff --git a/packages/rn-tester/js/examples/TextInput/TextInputExample.ios.js b/packages/rn-tester/js/examples/TextInput/TextInputExample.ios.js index a3e0621e8bfa..a6bcda4ec182 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 3aa30acc36ac..3cbc356b4a72 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()} + onSubmitEditing={() => this.ref5.current?.focus()} /> this.ref8.current?.focus()} - /> - this.ref9.current?.focus()} - /> - this.ref6.current?.focus()} /> @@ -1047,12 +962,6 @@ module.exports = [ return {examples}; }, }, - { - title: 'Blur on submit', - render: function (): React.MixedElement { - return ; - }, - }, { title: 'enterKeyHint modes', name: 'enterKeyHintTypes',