unify use of password and secureTextEntry for TextInput
Summary: Currently, the documentation shows both `password` and `secureTextEntry` as props for TextInput. However, the `password` prop is only passed to the Android component, so it does not work as expected for iOS developers. This PR prefers `password` over `secureTextEntry` but won't break anybody's code. Closes https://github.com/facebook/react-native/pull/622 Github Author: Will Piers <wpiers@rallydev.com> Test Plan: Imported from GitHub, without a `Test Plan:` line.
This commit is contained in:
parent
c29c595126
commit
c831328dcf
|
@ -251,7 +251,7 @@ exports.examples = [
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
<WithLabel label="true">
|
<WithLabel label="true">
|
||||||
<TextInput secureTextEntry={true} style={styles.default} value="abc" />
|
<TextInput password={true} style={styles.default} value="abc" />
|
||||||
</WithLabel>
|
</WithLabel>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|
|
@ -198,12 +198,6 @@ var TextInput = React.createClass({
|
||||||
* automatically enables it when there is text. Default value is false.
|
* automatically enables it when there is text. Default value is false.
|
||||||
*/
|
*/
|
||||||
enablesReturnKeyAutomatically: PropTypes.bool,
|
enablesReturnKeyAutomatically: PropTypes.bool,
|
||||||
|
|
||||||
/**
|
|
||||||
* If true, the text input obscures the text entered so that sensitive text
|
|
||||||
* like passwords stay secure. Default value is false.
|
|
||||||
*/
|
|
||||||
secureTextEntry: PropTypes.bool,
|
|
||||||
/**
|
/**
|
||||||
* If true, the text input can be multiple lines. Default value is false.
|
* If true, the text input can be multiple lines. Default value is false.
|
||||||
*/
|
*/
|
||||||
|
@ -221,11 +215,17 @@ var TextInput = React.createClass({
|
||||||
*/
|
*/
|
||||||
onChange: PropTypes.func,
|
onChange: PropTypes.func,
|
||||||
onChangeText: PropTypes.func,
|
onChangeText: PropTypes.func,
|
||||||
|
/**
|
||||||
|
* Callback that is called when text input ends.
|
||||||
|
*/
|
||||||
onEndEditing: PropTypes.func,
|
onEndEditing: PropTypes.func,
|
||||||
|
/**
|
||||||
|
* Callback that is called when the text input's submit button is pressed.
|
||||||
|
*/
|
||||||
onSubmitEditing: PropTypes.func,
|
onSubmitEditing: PropTypes.func,
|
||||||
/**
|
/**
|
||||||
* If true, the TextInput will be a password field. Default value is false.
|
* If true, the text input obscures the text entered so that sensitive text
|
||||||
|
* like passwords stay secure. Default value is false.
|
||||||
*/
|
*/
|
||||||
password: PropTypes.bool,
|
password: PropTypes.bool,
|
||||||
/**
|
/**
|
||||||
|
@ -419,7 +419,7 @@ var TextInput = React.createClass({
|
||||||
keyboardType={keyboardType}
|
keyboardType={keyboardType}
|
||||||
returnKeyType={returnKeyType}
|
returnKeyType={returnKeyType}
|
||||||
enablesReturnKeyAutomatically={this.props.enablesReturnKeyAutomatically}
|
enablesReturnKeyAutomatically={this.props.enablesReturnKeyAutomatically}
|
||||||
secureTextEntry={this.props.secureTextEntry}
|
secureTextEntry={this.props.password || this.props.secureTextEntry}
|
||||||
onFocus={this._onFocus}
|
onFocus={this._onFocus}
|
||||||
onBlur={this._onBlur}
|
onBlur={this._onBlur}
|
||||||
onChange={this._onChange}
|
onChange={this._onChange}
|
||||||
|
@ -464,7 +464,7 @@ var TextInput = React.createClass({
|
||||||
keyboardType={keyboardType}
|
keyboardType={keyboardType}
|
||||||
returnKeyType={returnKeyType}
|
returnKeyType={returnKeyType}
|
||||||
enablesReturnKeyAutomatically={this.props.enablesReturnKeyAutomatically}
|
enablesReturnKeyAutomatically={this.props.enablesReturnKeyAutomatically}
|
||||||
secureTextEntry={this.props.secureTextEntry}
|
secureTextEntry={this.props.password || this.props.secureTextEntry}
|
||||||
onFocus={this._onFocus}
|
onFocus={this._onFocus}
|
||||||
onBlur={this._onBlur}
|
onBlur={this._onBlur}
|
||||||
onChange={this._onChange}
|
onChange={this._onChange}
|
||||||
|
@ -505,7 +505,7 @@ var TextInput = React.createClass({
|
||||||
onChange={this._onChange}
|
onChange={this._onChange}
|
||||||
onEndEditing={this.props.onEndEditing}
|
onEndEditing={this.props.onEndEditing}
|
||||||
onSubmitEditing={this.props.onSubmitEditing}
|
onSubmitEditing={this.props.onSubmitEditing}
|
||||||
password={this.props.password}
|
password={this.props.password || this.props.secureTextEntry}
|
||||||
placeholder={this.props.placeholder}
|
placeholder={this.props.placeholder}
|
||||||
value={this.state.bufferedValue}
|
value={this.state.bufferedValue}
|
||||||
/>;
|
/>;
|
||||||
|
|
Loading…
Reference in New Issue