mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
(hopefully) fix auto-fill bug for safari/chrome
This commit is contained in:
parent
88b525f352
commit
1f8c8a7d9e
js/components/ascribe_forms
@ -39,13 +39,16 @@ let Form = React.createClass({
|
|||||||
// You can use the form for inline requests, like the submit click on a button.
|
// You can use the form for inline requests, like the submit click on a button.
|
||||||
// For the form to then not display the error on top, you need to enable this option.
|
// For the form to then not display the error on top, you need to enable this option.
|
||||||
// It will make use of the GlobalNotification
|
// It will make use of the GlobalNotification
|
||||||
isInline: React.PropTypes.bool
|
isInline: React.PropTypes.bool,
|
||||||
|
|
||||||
|
autoComplete: React.PropTypes.string
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps() {
|
getDefaultProps() {
|
||||||
return {
|
return {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
buttonSubmitText: 'SAVE'
|
buttonSubmitText: 'SAVE',
|
||||||
|
autoComplete: 'off'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -217,6 +220,25 @@ let Form = React.createClass({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All webkit-based browsers are ignoring the attribute autoComplete="off",
|
||||||
|
* as stated here: http://stackoverflow.com/questions/15738259/disabling-chrome-autofill/15917221#15917221
|
||||||
|
* So what we actually have to do is depended on whether or not this.props.autoComplete is set to "on" or "off"
|
||||||
|
* insert two fake hidden inputs that mock password and username so that chrome/safari is filling those
|
||||||
|
*/
|
||||||
|
getFakeAutocompletableInputs() {
|
||||||
|
if(this.props.autoComplete === 'off') {
|
||||||
|
return (
|
||||||
|
<span>
|
||||||
|
<input style={{display: 'none'}} type="text" name="fakeusernameremembered"/>
|
||||||
|
<input style={{display: 'none'}} type="password" name="fakepasswordremembered"/>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let className = 'ascribe-form';
|
let className = 'ascribe-form';
|
||||||
|
|
||||||
@ -229,7 +251,8 @@ let Form = React.createClass({
|
|||||||
role="form"
|
role="form"
|
||||||
className={className}
|
className={className}
|
||||||
onSubmit={this.submit}
|
onSubmit={this.submit}
|
||||||
autoComplete="on">
|
autoComplete={this.props.autoComplete}>
|
||||||
|
{this.getFakeAutocompletableInputs()}
|
||||||
{this.getErrors()}
|
{this.getErrors()}
|
||||||
{this.renderChildren()}
|
{this.renderChildren()}
|
||||||
{this.getButtons()}
|
{this.getButtons()}
|
||||||
|
@ -101,6 +101,7 @@ let LoginForm = React.createClass({
|
|||||||
ref="loginForm"
|
ref="loginForm"
|
||||||
url={ApiUrls.users_login}
|
url={ApiUrls.users_login}
|
||||||
handleSuccess={this.handleSuccess}
|
handleSuccess={this.handleSuccess}
|
||||||
|
autoComplete="on"
|
||||||
buttons={
|
buttons={
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
@ -121,7 +122,6 @@ let LoginForm = React.createClass({
|
|||||||
<input
|
<input
|
||||||
type="email"
|
type="email"
|
||||||
placeholder={getLangText('Enter your email')}
|
placeholder={getLangText('Enter your email')}
|
||||||
autoComplete="on"
|
|
||||||
name="username"
|
name="username"
|
||||||
required/>
|
required/>
|
||||||
</Property>
|
</Property>
|
||||||
@ -131,7 +131,6 @@ let LoginForm = React.createClass({
|
|||||||
<input
|
<input
|
||||||
type="password"
|
type="password"
|
||||||
placeholder={getLangText('Enter your password')}
|
placeholder={getLangText('Enter your password')}
|
||||||
autoComplete="on"
|
|
||||||
name="password"
|
name="password"
|
||||||
required/>
|
required/>
|
||||||
</Property>
|
</Property>
|
||||||
|
Loading…
Reference in New Issue
Block a user