diff options
author | tanhengyeow <E0032242@u.nus.edu> | 2020-06-19 00:17:45 +0800 |
---|---|---|
committer | tanhengyeow <E0032242@u.nus.edu> | 2020-06-19 00:17:45 +0800 |
commit | b6c1f45066da01cb28bbdd8e2d81c1c2bb8ed872 (patch) | |
tree | 1ed52f8568215b2f3b1f66ee5aa359a9baed783e | |
parent | a29532e27ab525381c751b2ffa7458451b2b87d2 (diff) | |
download | libeufin-b6c1f45066da01cb28bbdd8e2d81c1c2bb8ed872.tar.gz libeufin-b6c1f45066da01cb28bbdd8e2d81c1c2bb8ed872.tar.bz2 libeufin-b6c1f45066da01cb28bbdd8e2d81c1c2bb8ed872.zip |
Enable 'enter' keystroke support for login page
-rw-r--r-- | frontend/src/components/login/Index.tsx | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/frontend/src/components/login/Index.tsx b/frontend/src/components/login/Index.tsx index e73e234a..15f2b507 100644 --- a/frontend/src/components/login/Index.tsx +++ b/frontend/src/components/login/Index.tsx @@ -20,6 +20,21 @@ const Login = ({ loginConnect }: Props) => { wrapperCol: { span: 32 }, }; + const login = () => { + loginConnect(nexusURL, username, password) + .then(() => { + setAuthenticationFailure(false); + }) + .catch((err) => setAuthenticationFailure(true)); + }; + + const enterPressed = (event) => { + let code = event.keyCode || event.which; + if (code === 13) { + login(); + } + }; + return ( <div className="login"> {authenticationFailure ? ( @@ -43,25 +58,21 @@ const Login = ({ loginConnect }: Props) => { <Input placeholder="Username" onChange={(e) => setUsername(e.target.value)} + onKeyPress={(e) => enterPressed(e)} /> </Form.Item> <Form.Item> <Input.Password placeholder="Password" onChange={(e) => setPassword(e.target.value)} + onKeyPress={(e) => enterPressed(e)} /> </Form.Item> <div className="button"> <Button type="primary" icon={<LoginOutlined />} - onClick={() => - loginConnect(nexusURL, username, password) - .then(() => { - setAuthenticationFailure(false); - }) - .catch((err) => setAuthenticationFailure(true)) - } + onClick={() => login()} > Login </Button> |