diff --git a/src/components/views/login/PasswordLogin.js b/src/components/views/login/PasswordLogin.js index 16bd339825..a0e5ab0ddb 100644 --- a/src/components/views/login/PasswordLogin.js +++ b/src/components/views/login/PasswordLogin.js @@ -57,15 +57,17 @@ class PasswordLogin extends React.Component { this.onPhoneCountryChanged = this.onPhoneCountryChanged.bind(this); this.onPhoneNumberChanged = this.onPhoneNumberChanged.bind(this); this.onPasswordChanged = this.onPasswordChanged.bind(this); + this.isLoginEmpty = this.isLoginEmpty.bind(this); } componentWillMount() { this._passwordField = null; + this._loginField = null; } componentWillReceiveProps(nextProps) { if (!this.props.loginIncorrect && nextProps.loginIncorrect) { - field_input_incorrect(this._passwordField); + field_input_incorrect(this.isLoginEmpty() ? this._loginField : this._passwordField); } } @@ -157,8 +159,10 @@ class PasswordLogin extends React.Component { switch (loginType) { case PasswordLogin.LOGIN_FIELD_EMAIL: classes.mx_Login_email = true; + classes.error = this.props.loginIncorrect && !this.state.username; return {this._loginField = e;}} key="email_input" type="text" name="username" // make it a little easier for browser's remember-password @@ -170,8 +174,10 @@ class PasswordLogin extends React.Component { />; case PasswordLogin.LOGIN_FIELD_MXID: classes.mx_Login_username = true; + classes.error = this.props.loginIncorrect && !this.state.username; return {this._loginField = e;}} key="username_input" type="text" name="username" // make it a little easier for browser's remember-password @@ -184,14 +190,14 @@ class PasswordLogin extends React.Component { autoFocus disabled={disabled} />; - case PasswordLogin.LOGIN_FIELD_PHONE: + case PasswordLogin.LOGIN_FIELD_PHONE: { const CountryDropdown = sdk.getComponent('views.login.CountryDropdown'); classes.mx_Login_phoneNumberField = true; classes.mx_Login_field_has_prefix = true; + classes.error = this.props.loginIncorrect && !this.state.phoneNumber; return