Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
*
Expand Down
12 changes: 2 additions & 10 deletions packages/react-native/Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 3 additions & 4 deletions packages/react-native/ReactNativeApi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -6135,7 +6134,7 @@ export {
TaskProvider, // 266dedf2
Text, // f792e51d
TextContentType, // 239b3ecc
TextInput, // 1c32d882
TextInput, // 23c86495
TextInputAndroidProps, // 3f09ce49
TextInputBlurEvent, // b77af40e
TextInputChangeEvent, // f55eef98
Expand All @@ -6145,7 +6144,7 @@ export {
TextInputIOSProps, // 0d05a855
TextInputInstance, // 5a0c0e0d
TextInputKeyPressEvent, // 546c5d07
TextInputProps, // 08c36ff7
TextInputProps, // 2f454a43
TextInputSelectionChangeEvent, // e58f2abc
TextInputSubmitEditingEvent, // 6bcb2aa5
TextInstance, // 05463a96
Expand Down
20 changes: 0 additions & 20 deletions packages/rn-tester/js/examples/TextInput/TextInputExample.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import TextInputSharedExamples from './TextInputSharedExamples';
import * as React from 'react';
import {useRef} from 'react';
import {
Alert,
Button,
InputAccessoryView,
StyleSheet,
Expand Down Expand Up @@ -575,25 +574,6 @@ const textInputExamples: Array<RNTesterModuleExample> = [
);
},
},
{
title: 'Multiline blur on submit',
render: function (): React.Node {
return (
<View>
<ExampleTextInput
style={styles.multiline}
placeholder="blurOnSubmit = true"
returnKeyType="next"
blurOnSubmit={true}
multiline={true}
onSubmitEditing={event =>
Alert.alert('Alert', event.nativeEvent.text)
}
/>
</View>
);
},
},
{
title: 'Multiline',
render: function (): React.Node {
Expand Down
101 changes: 5 additions & 96 deletions packages/rn-tester/js/examples/TextInput/TextInputSharedExamples.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,62 +212,6 @@ class RewriteInvalidCharactersAndClearExample extends React.Component<

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

class BlurOnSubmitExample extends React.Component<{...}> {
ref1: ExampleRef = createRef();
ref2: ExampleRef = createRef();
ref3: ExampleRef = createRef();
ref4: ExampleRef = createRef();
ref5: ExampleRef = createRef();

render(): React.Node {
return (
<View>
<ExampleTextInput
ref={this.ref1}
style={styles.singleLine}
placeholder="blurOnSubmit = false"
returnKeyType="next"
blurOnSubmit={false}
onSubmitEditing={() => this.ref2.current?.focus()}
/>
<ExampleTextInput
ref={this.ref2}
style={styles.singleLine}
keyboardType="email-address"
placeholder="blurOnSubmit = false"
returnKeyType="next"
blurOnSubmit={false}
onSubmitEditing={() => this.ref3.current?.focus()}
/>
<ExampleTextInput
ref={this.ref3}
style={styles.singleLine}
keyboardType="url"
placeholder="blurOnSubmit = false"
returnKeyType="next"
blurOnSubmit={false}
onSubmitEditing={() => this.ref4.current?.focus()}
/>
<ExampleTextInput
ref={this.ref4}
style={styles.singleLine}
keyboardType="numeric"
placeholder="blurOnSubmit = false"
blurOnSubmit={false}
onSubmitEditing={() => this.ref5.current?.focus()}
/>
<ExampleTextInput
ref={this.ref5}
style={styles.singleLine}
keyboardType="numbers-and-punctuation"
placeholder="blurOnSubmit = true"
returnKeyType="done"
/>
</View>
);
}
}

class SubmitBehaviorExample extends React.Component<{...}> {
ref1: ExampleRef = createRef();
ref2: ExampleRef = createRef();
Expand All @@ -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 (
Expand All @@ -303,51 +243,26 @@ class SubmitBehaviorExample extends React.Component<{...}> {
/>
<ExampleTextInput
ref={this.ref4}
blurOnSubmit
placeholder="single line blurOnSubmit true"
onSubmitEditing={() => this.ref5.current?.focus()}
/>
<ExampleTextInput
ref={this.ref5}
blurOnSubmit={false}
placeholder="single line blurOnSubmit false"
onSubmitEditing={() => this.ref6.current?.focus()}
/>
<ExampleTextInput
ref={this.ref6}
multiline
placeholder="multiline submit"
submitBehavior="submit"
onSubmitEditing={() => this.ref7.current?.focus()}
onSubmitEditing={() => this.ref5.current?.focus()}
/>
<ExampleTextInput
ref={this.ref7}
ref={this.ref5}
multiline
placeholder="multiline blurAndSubmit"
submitBehavior="blurAndSubmit"
onSubmitEditing={() => this.ref8.current?.focus()}
/>
<ExampleTextInput
ref={this.ref8}
multiline
blurOnSubmit
placeholder="multiline blurOnSubmit true"
onSubmitEditing={() => this.ref9.current?.focus()}
/>
<ExampleTextInput
ref={this.ref9}
multiline
blurOnSubmit={false}
placeholder="multiline blurOnSubmit false"
onSubmitEditing={() => this.ref6.current?.focus()}
/>
<ExampleTextInput
ref={this.ref10}
ref={this.ref6}
multiline
placeholder="multiline newline"
submitBehavior="newline"
/>
<ExampleTextInput
ref={this.ref11}
ref={this.ref7}
multiline
placeholder="multiline default"
/>
Expand Down Expand Up @@ -1047,12 +962,6 @@ module.exports = [
return <View>{examples}</View>;
},
},
{
title: 'Blur on submit',
render: function (): React.MixedElement {
return <BlurOnSubmitExample />;
},
},
{
title: 'enterKeyHint modes',
name: 'enterKeyHintTypes',
Expand Down
Loading