mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Added blurOnSubmit support to multine TextInput (aka RCTTextView)
Summary: public Setting `blurOnSubmit=true` on a multiline `<TextInput>` now causes it to behave like a single-line input with respect to the return key: With the default value of `false`, pressing return will enter a newline character into the field. If you set the value to `true`, pressing return will now blur the field and trigger the onSubmitEditing event. The newline character will *not* be added to the text. (See associated github task for dicussion: https://github.com/facebook/react-native/pull/2149) Reviewed By: javache Differential Revision: D2710448 fb-gh-sync-id: c9706ae11f8b399932d3400ceb4c7558e455570d
This commit is contained in:
committed by
facebook-github-bot-9
parent
807e0d9310
commit
37042573b8
@@ -37,7 +37,7 @@ var onlyMultiline = {
|
||||
};
|
||||
|
||||
var notMultiline = {
|
||||
onSubmitEditing: true,
|
||||
// nothing yet
|
||||
};
|
||||
|
||||
if (Platform.OS === 'android') {
|
||||
@@ -47,10 +47,6 @@ if (Platform.OS === 'android') {
|
||||
var RCTTextField = requireNativeComponent('RCTTextField', null);
|
||||
}
|
||||
|
||||
type DefaultProps = {
|
||||
blurOnSubmit: boolean;
|
||||
};
|
||||
|
||||
type Event = Object;
|
||||
|
||||
/**
|
||||
@@ -73,17 +69,6 @@ type Event = Object;
|
||||
* ```
|
||||
*
|
||||
* Note that some props are only available with `multiline={true/false}`:
|
||||
* ```
|
||||
* var onlyMultiline = {
|
||||
* onSelectionChange: true, // not supported in Open Source yet
|
||||
* onTextInput: true, // not supported in Open Source yet
|
||||
* children: true,
|
||||
* };
|
||||
*
|
||||
* var notMultiline = {
|
||||
* onSubmitEditing: true,
|
||||
* };
|
||||
* ```
|
||||
*/
|
||||
var TextInput = React.createClass({
|
||||
statics: {
|
||||
@@ -304,7 +289,10 @@ var TextInput = React.createClass({
|
||||
selectTextOnFocus: PropTypes.bool,
|
||||
/**
|
||||
* If true, the text field will blur when submitted.
|
||||
* The default value is true.
|
||||
* 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.
|
||||
* @platform ios
|
||||
*/
|
||||
blurOnSubmit: PropTypes.bool,
|
||||
@@ -323,12 +311,6 @@ var TextInput = React.createClass({
|
||||
underlineColorAndroid: PropTypes.string,
|
||||
},
|
||||
|
||||
getDefaultProps: function(): DefaultProps {
|
||||
return {
|
||||
blurOnSubmit: true,
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* `NativeMethodsMixin` will look for this when invoking `setNativeProps`. We
|
||||
* make `this` look like an actual native component class.
|
||||
|
||||
Reference in New Issue
Block a user