Skip to content

Commit 6622940

Browse files
committed
Remove TextInput blurOnSubmit
# Conflicts: # packages/react-native/ReactNativeApi.d.ts
1 parent d9d2502 commit 6622940

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
@@ -530,20 +530,6 @@ export type AndroidTextInputNativeProps = Readonly<{
530530
*/
531531
selectTextOnFocus?: ?boolean,
532532

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

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -756,20 +756,6 @@ export interface TextInputProps
756756
*/
757757
autoFocus?: boolean | undefined;
758758

759-
/**
760-
* If `true`, the text field will blur when submitted.
761-
* The default value is true for single-line fields and false for
762-
* multiline fields. Note that for multiline fields, setting `blurOnSubmit`
763-
* to `true` means that pressing return will blur the field and trigger the
764-
* `onSubmitEditing` event instead of inserting a newline into the field.
765-
*
766-
* @deprecated
767-
* Note that `submitBehavior` now takes the place of `blurOnSubmit` and will
768-
* override any behavior defined by `blurOnSubmit`.
769-
* @see submitBehavior
770-
*/
771-
blurOnSubmit?: boolean | undefined;
772-
773759
/**
774760
* When the return key is pressed,
775761
*

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -986,20 +986,6 @@ type TextInputBaseProps = Readonly<{
986986
*/
987987
selectTextOnFocus?: ?boolean,
988988

989-
/**
990-
* If `true`, the text field will blur when submitted.
991-
* The default value is true for single-line fields and false for
992-
* multiline fields. Note that for multiline fields, setting `blurOnSubmit`
993-
* to `true` means that pressing return will blur the field and trigger the
994-
* `onSubmitEditing` event instead of inserting a newline into the field.
995-
*
996-
* @deprecated
997-
* Note that `submitBehavior` now takes the place of `blurOnSubmit` and will
998-
* override any behavior defined by `blurOnSubmit`.
999-
* @see submitBehavior
1000-
*/
1001-
blurOnSubmit?: ?boolean,
1002-
1003989
/**
1004990
* When the return key is pressed,
1005991
*

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
@@ -280,7 +280,7 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
280280
[self _setShowSoftInputOnFocus:newTextInputProps.traits.showSoftInputOnFocus];
281281
}
282282

283-
// Traits `blurOnSubmit`, `clearTextOnFocus`, and `selectTextOnFocus` were omitted intentionally here
283+
// Traits `clearTextOnFocus` and `selectTextOnFocus` were omitted intentionally here
284284
// because they are being checked on-demand.
285285

286286
// 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<<10889ead2857238c3286b036b73f9945>>
7+
* @generated SignedSource<<1520a859c8e21a9257a845acbf1d2923>>
88
*
99
* This file was generated by scripts/js-api/build-types/index.js.
1010
*/
@@ -5152,7 +5152,6 @@ declare type TextInputBaseProps = {
51525152
| "wifi-password"
51535153
readonly autoCorrect?: boolean
51545154
readonly autoFocus?: boolean
5155-
readonly blurOnSubmit?: boolean
51565155
readonly caretHidden?: boolean
51575156
readonly contextMenuHidden?: boolean
51585157
readonly defaultValue?: string
@@ -6158,7 +6157,7 @@ export {
61586157
TaskProvider, // 266dedf2
61596158
Text, // f792e51d
61606159
TextContentType, // 239b3ecc
6161-
TextInput, // 1c32d882
6160+
TextInput, // 23c86495
61626161
TextInputAndroidProps, // 3f09ce49
61636162
TextInputBlurEvent, // b77af40e
61646163
TextInputChangeEvent, // f55eef98
@@ -6168,7 +6167,7 @@ export {
61686167
TextInputIOSProps, // 0d05a855
61696168
TextInputInstance, // 5a0c0e0d
61706169
TextInputKeyPressEvent, // 546c5d07
6171-
TextInputProps, // 08c36ff7
6170+
TextInputProps, // 2f454a43
61726171
TextInputSelectionChangeEvent, // e58f2abc
61736172
TextInputSubmitEditingEvent, // 6bcb2aa5
61746173
TextInstance, // 05463a96

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
/>
@@ -1047,12 +962,6 @@ module.exports = [
1047962
return <View>{examples}</View>;
1048963
},
1049964
},
1050-
{
1051-
title: 'Blur on submit',
1052-
render: function (): React.MixedElement {
1053-
return <BlurOnSubmitExample />;
1054-
},
1055-
},
1056965
{
1057966
title: 'enterKeyHint modes',
1058967
name: 'enterKeyHintTypes',

0 commit comments

Comments
 (0)