Merge pull request #4441 from matrix-org/t3chguy/login-tab
Password Login make sure tab takes user to password fieldpull/21833/head
commit
ccc1f1fe37
|
@ -185,7 +185,7 @@ export default class PasswordLogin extends React.Component {
|
||||||
this.props.onPasswordChanged(ev.target.value);
|
this.props.onPasswordChanged(ev.target.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderLoginField(loginType) {
|
renderLoginField(loginType, autoFocus) {
|
||||||
const Field = sdk.getComponent('elements.Field');
|
const Field = sdk.getComponent('elements.Field');
|
||||||
|
|
||||||
const classes = {};
|
const classes = {};
|
||||||
|
@ -204,7 +204,7 @@ export default class PasswordLogin extends React.Component {
|
||||||
onChange={this.onUsernameChanged}
|
onChange={this.onUsernameChanged}
|
||||||
onBlur={this.onUsernameBlur}
|
onBlur={this.onUsernameBlur}
|
||||||
disabled={this.props.disableSubmit}
|
disabled={this.props.disableSubmit}
|
||||||
autoFocus
|
autoFocus={autoFocus}
|
||||||
/>;
|
/>;
|
||||||
case PasswordLogin.LOGIN_FIELD_MXID:
|
case PasswordLogin.LOGIN_FIELD_MXID:
|
||||||
classes.error = this.props.loginIncorrect && !this.state.username;
|
classes.error = this.props.loginIncorrect && !this.state.username;
|
||||||
|
@ -218,7 +218,7 @@ export default class PasswordLogin extends React.Component {
|
||||||
onChange={this.onUsernameChanged}
|
onChange={this.onUsernameChanged}
|
||||||
onBlur={this.onUsernameBlur}
|
onBlur={this.onUsernameBlur}
|
||||||
disabled={this.props.disableSubmit}
|
disabled={this.props.disableSubmit}
|
||||||
autoFocus
|
autoFocus={autoFocus}
|
||||||
/>;
|
/>;
|
||||||
case PasswordLogin.LOGIN_FIELD_PHONE: {
|
case PasswordLogin.LOGIN_FIELD_PHONE: {
|
||||||
const CountryDropdown = sdk.getComponent('views.auth.CountryDropdown');
|
const CountryDropdown = sdk.getComponent('views.auth.CountryDropdown');
|
||||||
|
@ -242,7 +242,7 @@ export default class PasswordLogin extends React.Component {
|
||||||
onChange={this.onPhoneNumberChanged}
|
onChange={this.onPhoneNumberChanged}
|
||||||
onBlur={this.onPhoneNumberBlur}
|
onBlur={this.onPhoneNumberBlur}
|
||||||
disabled={this.props.disableSubmit}
|
disabled={this.props.disableSubmit}
|
||||||
autoFocus
|
autoFocus={autoFocus}
|
||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,10 @@ export default class PasswordLogin extends React.Component {
|
||||||
error: this.props.loginIncorrect && !this.isLoginEmpty(), // only error password if error isn't top field
|
error: this.props.loginIncorrect && !this.isLoginEmpty(), // only error password if error isn't top field
|
||||||
});
|
});
|
||||||
|
|
||||||
const loginField = this.renderLoginField(this.state.loginType);
|
// If login is empty, autoFocus login, otherwise autoFocus password.
|
||||||
|
// this is for when auto server discovery remounts us when the user tries to tab from username to password
|
||||||
|
const autoFocusPassword = !this.isLoginEmpty();
|
||||||
|
const loginField = this.renderLoginField(this.state.loginType, !autoFocusPassword);
|
||||||
|
|
||||||
let loginType;
|
let loginType;
|
||||||
if (!SdkConfig.get().disable_3pid_login) {
|
if (!SdkConfig.get().disable_3pid_login) {
|
||||||
|
@ -336,6 +339,7 @@ export default class PasswordLogin extends React.Component {
|
||||||
value={this.state.password}
|
value={this.state.password}
|
||||||
onChange={this.onPasswordChanged}
|
onChange={this.onPasswordChanged}
|
||||||
disabled={this.props.disableSubmit}
|
disabled={this.props.disableSubmit}
|
||||||
|
autoFocus={autoFocusPassword}
|
||||||
/>
|
/>
|
||||||
{forgotPasswordJsx}
|
{forgotPasswordJsx}
|
||||||
{ !this.props.busy && <input className="mx_Login_submit"
|
{ !this.props.busy && <input className="mx_Login_submit"
|
||||||
|
|
Loading…
Reference in New Issue