commit b6c1f45066da01cb28bbdd8e2d81c1c2bb8ed872
parent a29532e27ab525381c751b2ffa7458451b2b87d2
Author: tanhengyeow <E0032242@u.nus.edu>
Date: Fri, 19 Jun 2020 00:17:45 +0800
Enable 'enter' keystroke support for login page
Diffstat:
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git 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>