Răsfoiți Sursa

Disable login inputs until the page is completely loaded.

Autofill will no longer conflict with what the user currently types in slow connection.
Updated the input's disabled state style.
Sergiu Miclea 8 ani în urmă
părinte
comite
8b12e0c512
2 a modificat fișierele cu 13 adăugiri și 2 ștergeri
  1. 2 1
      src/components/App/App.scss
  2. 11 1
      src/components/LoginPage/LoginPage.js

+ 2 - 1
src/components/App/App.scss

@@ -845,7 +845,8 @@ input[type="text"], input[type="password"] {
     outline: none;
     outline: none;
   }
   }
   &:disabled {
   &:disabled {
-    border-color: $gray-dark;
+    color: $gray;
+    border-color: $gray-lighter;
     background-color: $gray-lighter;
     background-color: $gray-lighter;
   }
   }
 }
 }

+ 11 - 1
src/components/LoginPage/LoginPage.js

@@ -92,9 +92,17 @@ export class LoginPage extends Reflux.Component {
   }
   }
 
 
   componentWillMount() {
   componentWillMount() {
+    if (process.env.BROWSER) {
+      window.addEventListener('load', this.handleWindowLoad.bind(this));
+    }
+
     super.componentWillMount.call(this)
     super.componentWillMount.call(this)
     this.context.onSetTitle(title);
     this.context.onSetTitle(title);
+  }
+
+  handleWindowLoad() {
     this.setState({ disableLogin: false })
     this.setState({ disableLogin: false })
+    this.userNameInput.focus()
   }
   }
 
 
   login(e) {
   login(e) {
@@ -160,8 +168,9 @@ export class LoginPage extends Reflux.Component {
                 <div className="form-group">
                 <div className="form-group">
                   <label>Username</label>
                   <label>Username</label>
                   <input
                   <input
+                    ref={input => { this.userNameInput = input }}
+                    disabled={this.state.disableLogin}
                     type="text"
                     type="text"
-                    autoFocus="true"
                     placeholder="Username"
                     placeholder="Username"
                     onChange={(e) => this.handleChangeUsername(e)}
                     onChange={(e) => this.handleChangeUsername(e)}
                     value={this.state.username}
                     value={this.state.username}
@@ -170,6 +179,7 @@ export class LoginPage extends Reflux.Component {
                 <div className="form-group">
                 <div className="form-group">
                   <label>Password</label>
                   <label>Password</label>
                   <input
                   <input
+                    disabled={this.state.disableLogin}
                     type="password"
                     type="password"
                     placeholder="Password"
                     placeholder="Password"
                     onChange={(e) => this.handleChangePassword(e)}
                     onChange={(e) => this.handleChangePassword(e)}