diff options
author | Anton Tananaev <anton@traccar.org> | 2024-03-25 17:32:02 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2024-03-25 17:32:02 -0700 |
commit | f2be5ab566dfa07d27d4e84052a673fe36ec3363 (patch) | |
tree | fc055bdd4eee0cf8e67632218315471b7ba1e333 /modern | |
parent | 393f89503c808b85bf4644ff692cb9ce6c2bb3ed (diff) | |
download | trackermap-web-f2be5ab566dfa07d27d4e84052a673fe36ec3363.tar.gz trackermap-web-f2be5ab566dfa07d27d4e84052a673fe36ec3363.tar.bz2 trackermap-web-f2be5ab566dfa07d27d4e84052a673fe36ec3363.zip |
Better enter button handing
Diffstat (limited to 'modern')
-rw-r--r-- | modern/src/login/LoginPage.jsx | 11 | ||||
-rw-r--r-- | modern/src/login/RegisterPage.jsx | 4 |
2 files changed, 4 insertions, 11 deletions
diff --git a/modern/src/login/LoginPage.jsx b/modern/src/login/LoginPage.jsx index 62aa4a6b..2dac3846 100644 --- a/modern/src/login/LoginPage.jsx +++ b/modern/src/login/LoginPage.jsx @@ -125,12 +125,6 @@ const LoginPage = () => { } }); - const handleSpecialKey = (e) => { - if (e.keyCode === 13 && email && password && (!codeEnabled || code)) { - handlePasswordLogin(e); - } - }; - const handleOpenIdLogin = () => { document.location = '/api/session/openid/auth'; }; @@ -170,7 +164,6 @@ const LoginPage = () => { autoComplete="email" autoFocus={!email} onChange={(e) => setEmail(e.target.value)} - onKeyUp={handleSpecialKey} helperText={failed && 'Invalid username or password'} /> <TextField @@ -183,7 +176,6 @@ const LoginPage = () => { autoComplete="current-password" autoFocus={!!email} onChange={(e) => setPassword(e.target.value)} - onKeyUp={handleSpecialKey} /> {codeEnabled && ( <TextField @@ -194,12 +186,11 @@ const LoginPage = () => { value={code} type="number" onChange={(e) => setCode(e.target.value)} - onKeyUp={handleSpecialKey} /> )} <Button onClick={handlePasswordLogin} - onKeyUp={handleSpecialKey} + type="submit" variant="contained" color="secondary" disabled={!email || !password || (codeEnabled && !code)} diff --git a/modern/src/login/RegisterPage.jsx b/modern/src/login/RegisterPage.jsx index cffed803..4e2a05e1 100644 --- a/modern/src/login/RegisterPage.jsx +++ b/modern/src/login/RegisterPage.jsx @@ -56,7 +56,8 @@ const RegisterPage = () => { } }, [totpForce, setTotpKey]); - const handleSubmit = useCatch(async () => { + const handleSubmit = useCatch(async (event) => { + event.preventDefault(); const response = await fetch('/api/users', { method: 'POST', headers: { 'Content-Type': 'application/json' }, @@ -124,6 +125,7 @@ const RegisterPage = () => { variant="contained" color="secondary" onClick={handleSubmit} + type="submit" disabled={!name || !password || !(server.newServer || /(.+)@(.+)\.(.{2,})/.test(email))} fullWidth > |