mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-09 17:13:46 +08:00
Implements blurOnSubmit
Summary: The default value (to retain current behavior) is set to `true`. Setting the value to `false` will prevent the textField from blurring but still fire the `onSubmitEditing` callback. However, the `onEndEditing` callback will not be fired. Addresses issue: https://github.com/facebook/react-native/issues/2129 Closes https://github.com/facebook/react-native/pull/2149 Reviewed By: svcscm Differential Revision: D2619822 Pulled By: nicklockwood fb-gh-sync-id: 9a61152892f4afb5c6c53e7b38dffae13bc7e13f
This commit is contained in:
committed by
facebook-github-bot-6
parent
66f7feda4d
commit
7af752403e
@@ -120,6 +120,60 @@ class RewriteExample extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
var BlurOnSubmitExample = React.createClass({
|
||||
focusNextField(nextField) {
|
||||
this.refs[nextField].focus()
|
||||
},
|
||||
|
||||
render: function() {
|
||||
return (
|
||||
<View>
|
||||
<TextInput
|
||||
ref='1'
|
||||
style={styles.default}
|
||||
placeholder='blurOnSubmit = false'
|
||||
returnKeyType='next'
|
||||
blurOnSubmit={false}
|
||||
onSubmitEditing={() => this.focusNextField('2')}
|
||||
/>
|
||||
<TextInput
|
||||
ref='2'
|
||||
style={styles.default}
|
||||
keyboardType='email-address'
|
||||
placeholder='blurOnSubmit = false'
|
||||
returnKeyType='next'
|
||||
blurOnSubmit={false}
|
||||
onSubmitEditing={() => this.focusNextField('3')}
|
||||
/>
|
||||
<TextInput
|
||||
ref='3'
|
||||
style={styles.default}
|
||||
keyboardType='url'
|
||||
placeholder='blurOnSubmit = false'
|
||||
returnKeyType='next'
|
||||
blurOnSubmit={false}
|
||||
onSubmitEditing={() => this.focusNextField('4')}
|
||||
/>
|
||||
<TextInput
|
||||
ref='4'
|
||||
style={styles.default}
|
||||
keyboardType='numeric'
|
||||
placeholder='blurOnSubmit = false'
|
||||
blurOnSubmit={false}
|
||||
onSubmitEditing={() => this.focusNextField('5')}
|
||||
/>
|
||||
<TextInput
|
||||
ref='5'
|
||||
style={styles.default}
|
||||
keyboardType='numbers-and-punctuation'
|
||||
placeholder='blurOnSubmit = true'
|
||||
returnKeyType='done'
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
page: {
|
||||
paddingBottom: 300,
|
||||
@@ -443,5 +497,9 @@ exports.examples = [
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: 'Blur on submit',
|
||||
render: function(): ReactElement { return <BlurOnSubmitExample />; },
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user