mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
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
This commit is contained in:
1 parent
765d153ece
commit
ab373989c3
8 files changed
+13
-175
No files matched your search
-14
@@ -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,
|
||||
*
|
||||
|
||||
@@ -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,
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -289,7 +289,7 @@ static NSSet<NSNumber *> *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:
|
||||
|
||||
+3
-4
@@ -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<<de4784287f01d64940f12c9eb85e4b01>>
|
||||
*
|
||||
* 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
|
||||
|
||||
-14
@@ -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,
|
||||
*
|
||||
|
||||
@@ -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<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 {
|
||||
|
||||
@@ -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();
|
||||
@@ -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<{...}> {
|
||||
/>
|
||||
<ExampleTextInput
|
||||
ref={this.ref4}
|
||||
blurOnSubmit
|
||||
placeholder="single line blurOnSubmit true"
|
||||
multiline
|
||||
placeholder="multiline submit"
|
||||
submitBehavior="submit"
|
||||
onSubmitEditing={() => this.ref5.current?.focus()}
|
||||
/>
|
||||
<ExampleTextInput
|
||||
ref={this.ref5}
|
||||
blurOnSubmit={false}
|
||||
placeholder="single line blurOnSubmit false"
|
||||
multiline
|
||||
placeholder="multiline blurAndSubmit"
|
||||
submitBehavior="blurAndSubmit"
|
||||
onSubmitEditing={() => this.ref6.current?.focus()}
|
||||
/>
|
||||
<ExampleTextInput
|
||||
ref={this.ref6}
|
||||
multiline
|
||||
placeholder="multiline submit"
|
||||
submitBehavior="submit"
|
||||
onSubmitEditing={() => this.ref7.current?.focus()}
|
||||
/>
|
||||
<ExampleTextInput
|
||||
ref={this.ref7}
|
||||
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"
|
||||
/>
|
||||
<ExampleTextInput
|
||||
ref={this.ref10}
|
||||
multiline
|
||||
placeholder="multiline newline"
|
||||
submitBehavior="newline"
|
||||
/>
|
||||
<ExampleTextInput
|
||||
ref={this.ref11}
|
||||
ref={this.ref7}
|
||||
multiline
|
||||
placeholder="multiline default"
|
||||
/>
|
||||
@@ -1049,12 +964,6 @@ module.exports = [
|
||||
return <View>{examples}</View>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Blur on submit',
|
||||
render: function (): React.MixedElement {
|
||||
return <BlurOnSubmitExample />;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'enterKeyHint modes',
|
||||
name: 'enterKeyHintTypes',
|
||||
|
||||
Reference in new issue
Block a user