Skip to content

Commit ab37398

Browse files
zoontekmeta-codesync[bot]
authored andcommitted
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 #57384 ## Changelog: [GENERAL] [REMOVED] - Remove deprecated `TextInput` `blurOnSubmit` prop (use `submitBehavior` instead) Pull Request resolved: #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
1 parent 765d153 commit ab37398

8 files changed

Lines changed: 11 additions & 173 deletions

File tree

‎packages/react-native/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -533,20 +533,6 @@ export type AndroidTextInputNativeProps = Readonly<{
533533
*/
534534
selectTextOnFocus?: ?boolean,
535535

536-
/**
537-
* If `true`, the text field will blur when submitted.
538-
* The default value is true for single-line fields and false for
539-
* multiline fields. Note that for multiline fields, setting `blurOnSubmit`
540-
* to `true` means that pressing return will blur the field and trigger the
541-
* `onSubmitEditing` event instead of inserting a newline into the field.
542-
*
543-
* @deprecated
544-
* Note that `submitBehavior` now takes the place of `blurOnSubmit` and will
545-
* override any behavior defined by `blurOnSubmit`.
546-
* @see submitBehavior
547-
*/
548-
blurOnSubmit?: ?boolean,
549-
550536
/**
551537
* When the return key is pressed,
552538
*

‎packages/react-native/Libraries/Components/TextInput/TextInput.flow.js‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -965,20 +965,6 @@ type TextInputBaseProps = Readonly<{
965965
*/
966966
selectTextOnFocus?: ?boolean,
967967

968-
/**
969-
* If `true`, the text field will blur when submitted.
970-
* The default value is true for single-line fields and false for
971-
* multiline fields. Note that for multiline fields, setting `blurOnSubmit`
972-
* to `true` means that pressing return will blur the field and trigger the
973-
* `onSubmitEditing` event instead of inserting a newline into the field.
974-
*
975-
* @deprecated
976-
* Note that `submitBehavior` now takes the place of `blurOnSubmit` and will
977-
* override any behavior defined by `blurOnSubmit`.
978-
* @see submitBehavior
979-
*/
980-
blurOnSubmit?: ?boolean,
981-
982968
/**
983969
* When the return key is pressed,
984970
*

‎packages/react-native/Libraries/Components/TextInput/TextInput.js‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -456,18 +456,10 @@ function InternalTextInput(props: TextInputProps): React.Node {
456456
submitBehavior = props.submitBehavior;
457457
}
458458
} else if (multiline) {
459-
if (props.blurOnSubmit === true) {
460-
submitBehavior = 'blurAndSubmit';
461-
} else {
462-
submitBehavior = 'newline';
463-
}
459+
submitBehavior = 'newline';
464460
} else {
465461
// Single line
466-
if (props.blurOnSubmit !== false) {
467-
submitBehavior = 'blurAndSubmit';
468-
} else {
469-
submitBehavior = 'submit';
470-
}
462+
submitBehavior = 'blurAndSubmit';
471463
}
472464

473465
const accessible = props.accessible !== false;

‎packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
289289
[self _setShowSoftInputOnFocus:newTextInputProps.traits.showSoftInputOnFocus];
290290
}
291291

292-
// Traits `blurOnSubmit`, `clearTextOnFocus`, and `selectTextOnFocus` were omitted intentionally here
292+
// Traits `clearTextOnFocus` and `selectTextOnFocus` were omitted intentionally here
293293
// because they are being checked on-demand.
294294

295295
// Other props:

‎packages/react-native/ReactNativeApi.d.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<2e80ab7a8c4c5de55dc0f7cd7a7be0ed>>
7+
* @generated SignedSource<<de4784287f01d64940f12c9eb85e4b01>>
88
*
99
* This file was generated by scripts/js-api/build-types/index.js.
1010
*/
@@ -5013,7 +5013,6 @@ declare type TextInputBaseProps = {
50135013
| "wifi-password"
50145014
readonly autoCorrect?: boolean
50155015
readonly autoFocus?: boolean
5016-
readonly blurOnSubmit?: boolean
50175016
readonly caretHidden?: boolean
50185017
readonly contextMenuHidden?: boolean
50195018
readonly defaultValue?: string
@@ -6006,7 +6005,7 @@ export {
60066005
TaskProvider, // 266dedf2
60076006
Text, // d023b11d
60086007
TextContentType, // 239b3ecc
6009-
TextInput, // 0aec86ba
6008+
TextInput, // b7d29fe7
60106009
TextInputAndroidProps, // 9ebbc103
60116010
TextInputBlurEvent, // b4c7a58c
60126011
TextInputChangeEvent, // 92363e10
@@ -6016,7 +6015,7 @@ export {
60166015
TextInputIOSProps, // fb3c9327
60176016
TextInputInstance, // 53fe7b73
60186017
TextInputKeyPressEvent, // cbbc322a
6019-
TextInputProps, // 88ef6be8
6018+
TextInputProps, // 21d5b23c
60206019
TextInputSelectionChangeEvent, // 4a8f10c2
60216020
TextInputSubmitEditingEvent, // e811fdbd
60226021
TextInstance, // 7c7e2069

‎packages/react-native/types_DEPRECATED/Libraries/Components/TextInput/TextInput.d.ts‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -726,20 +726,6 @@ export interface TextInputProps
726726
*/
727727
autoFocus?: boolean | undefined;
728728

729-
/**
730-
* If `true`, the text field will blur when submitted.
731-
* The default value is true for single-line fields and false for
732-
* multiline fields. Note that for multiline fields, setting `blurOnSubmit`
733-
* to `true` means that pressing return will blur the field and trigger the
734-
* `onSubmitEditing` event instead of inserting a newline into the field.
735-
*
736-
* @deprecated
737-
* Note that `submitBehavior` now takes the place of `blurOnSubmit` and will
738-
* override any behavior defined by `blurOnSubmit`.
739-
* @see submitBehavior
740-
*/
741-
blurOnSubmit?: boolean | undefined;
742-
743729
/**
744730
* When the return key is pressed,
745731
*

‎packages/rn-tester/js/examples/TextInput/TextInputExample.ios.js‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import TextInputSharedExamples from './TextInputSharedExamples';
2222
import * as React from 'react';
2323
import {useRef} from 'react';
2424
import {
25-
Alert,
2625
Button,
2726
InputAccessoryView,
2827
StyleSheet,
@@ -575,25 +574,6 @@ const textInputExamples: Array<RNTesterModuleExample> = [
575574
);
576575
},
577576
},
578-
{
579-
title: 'Multiline blur on submit',
580-
render: function (): React.Node {
581-
return (
582-
<View>
583-
<ExampleTextInput
584-
style={styles.multiline}
585-
placeholder="blurOnSubmit = true"
586-
returnKeyType="next"
587-
blurOnSubmit={true}
588-
multiline={true}
589-
onSubmitEditing={event =>
590-
Alert.alert('Alert', event.nativeEvent.text)
591-
}
592-
/>
593-
</View>
594-
);
595-
},
596-
},
597577
{
598578
title: 'Multiline',
599579
render: function (): React.Node {

‎packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js‎

Lines changed: 5 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -212,62 +212,6 @@ class RewriteInvalidCharactersAndClearExample extends React.Component<
212212

213213
type ExampleRef = {current: null | React.ElementRef<typeof ExampleTextInput>};
214214

215-
class BlurOnSubmitExample extends React.Component<{...}> {
216-
ref1: ExampleRef = createRef();
217-
ref2: ExampleRef = createRef();
218-
ref3: ExampleRef = createRef();
219-
ref4: ExampleRef = createRef();
220-
ref5: ExampleRef = createRef();
221-
222-
render(): React.Node {
223-
return (
224-
<View>
225-
<ExampleTextInput
226-
ref={this.ref1}
227-
style={styles.singleLine}
228-
placeholder="blurOnSubmit = false"
229-
returnKeyType="next"
230-
blurOnSubmit={false}
231-
onSubmitEditing={() => this.ref2.current?.focus()}
232-
/>
233-
<ExampleTextInput
234-
ref={this.ref2}
235-
style={styles.singleLine}
236-
keyboardType="email-address"
237-
placeholder="blurOnSubmit = false"
238-
returnKeyType="next"
239-
blurOnSubmit={false}
240-
onSubmitEditing={() => this.ref3.current?.focus()}
241-
/>
242-
<ExampleTextInput
243-
ref={this.ref3}
244-
style={styles.singleLine}
245-
keyboardType="url"
246-
placeholder="blurOnSubmit = false"
247-
returnKeyType="next"
248-
blurOnSubmit={false}
249-
onSubmitEditing={() => this.ref4.current?.focus()}
250-
/>
251-
<ExampleTextInput
252-
ref={this.ref4}
253-
style={styles.singleLine}
254-
keyboardType="numeric"
255-
placeholder="blurOnSubmit = false"
256-
blurOnSubmit={false}
257-
onSubmitEditing={() => this.ref5.current?.focus()}
258-
/>
259-
<ExampleTextInput
260-
ref={this.ref5}
261-
style={styles.singleLine}
262-
keyboardType="numbers-and-punctuation"
263-
placeholder="blurOnSubmit = true"
264-
returnKeyType="done"
265-
/>
266-
</View>
267-
);
268-
}
269-
}
270-
271215
class SubmitBehaviorExample extends React.Component<{...}> {
272216
ref1: ExampleRef = createRef();
273217
ref2: ExampleRef = createRef();
@@ -276,10 +220,6 @@ class SubmitBehaviorExample extends React.Component<{...}> {
276220
ref5: ExampleRef = createRef();
277221
ref6: ExampleRef = createRef();
278222
ref7: ExampleRef = createRef();
279-
ref8: ExampleRef = createRef();
280-
ref9: ExampleRef = createRef();
281-
ref10: ExampleRef = createRef();
282-
ref11: ExampleRef = createRef();
283223

284224
render(): React.Node {
285225
return (
@@ -303,51 +243,26 @@ class SubmitBehaviorExample extends React.Component<{...}> {
303243
/>
304244
<ExampleTextInput
305245
ref={this.ref4}
306-
blurOnSubmit
307-
placeholder="single line blurOnSubmit true"
308-
onSubmitEditing={() => this.ref5.current?.focus()}
309-
/>
310-
<ExampleTextInput
311-
ref={this.ref5}
312-
blurOnSubmit={false}
313-
placeholder="single line blurOnSubmit false"
314-
onSubmitEditing={() => this.ref6.current?.focus()}
315-
/>
316-
<ExampleTextInput
317-
ref={this.ref6}
318246
multiline
319247
placeholder="multiline submit"
320248
submitBehavior="submit"
321-
onSubmitEditing={() => this.ref7.current?.focus()}
249+
onSubmitEditing={() => this.ref5.current?.focus()}
322250
/>
323251
<ExampleTextInput
324-
ref={this.ref7}
252+
ref={this.ref5}
325253
multiline
326254
placeholder="multiline blurAndSubmit"
327255
submitBehavior="blurAndSubmit"
328-
onSubmitEditing={() => this.ref8.current?.focus()}
329-
/>
330-
<ExampleTextInput
331-
ref={this.ref8}
332-
multiline
333-
blurOnSubmit
334-
placeholder="multiline blurOnSubmit true"
335-
onSubmitEditing={() => this.ref9.current?.focus()}
336-
/>
337-
<ExampleTextInput
338-
ref={this.ref9}
339-
multiline
340-
blurOnSubmit={false}
341-
placeholder="multiline blurOnSubmit false"
256+
onSubmitEditing={() => this.ref6.current?.focus()}
342257
/>
343258
<ExampleTextInput
344-
ref={this.ref10}
259+
ref={this.ref6}
345260
multiline
346261
placeholder="multiline newline"
347262
submitBehavior="newline"
348263
/>
349264
<ExampleTextInput
350-
ref={this.ref11}
265+
ref={this.ref7}
351266
multiline
352267
placeholder="multiline default"
353268
/>
@@ -1049,12 +964,6 @@ module.exports = [
1049964
return <View>{examples}</View>;
1050965
},
1051966
},
1052-
{
1053-
title: 'Blur on submit',
1054-
render: function (): React.MixedElement {
1055-
return <BlurOnSubmitExample />;
1056-
},
1057-
},
1058967
{
1059968
title: 'enterKeyHint modes',
1060969
name: 'enterKeyHintTypes',

0 commit comments

Comments
 (0)