aboutsummaryrefslogtreecommitdiff
path: root/modern/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-09-05 10:53:02 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-09-05 10:53:02 -0700
commit86fe92f00a1bdf73e1ecc6c1625d4d6fbad4e4a5 (patch)
tree6f2d824ea32e868f132bd5ef2b433ff29c6fa222 /modern/src
parenta5a46eaa4ba0c8f444686235b6d6d934cc2a69da (diff)
downloadtrackermap-web-86fe92f00a1bdf73e1ecc6c1625d4d6fbad4e4a5.tar.gz
trackermap-web-86fe92f00a1bdf73e1ecc6c1625d4d6fbad4e4a5.tar.bz2
trackermap-web-86fe92f00a1bdf73e1ecc6c1625d4d6fbad4e4a5.zip
Persist email value
Diffstat (limited to 'modern/src')
-rw-r--r--modern/src/components/registration/LoginForm.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/modern/src/components/registration/LoginForm.js b/modern/src/components/registration/LoginForm.js
index 8775a98e..bbb5d5fb 100644
--- a/modern/src/components/registration/LoginForm.js
+++ b/modern/src/components/registration/LoginForm.js
@@ -8,6 +8,7 @@ import { useHistory } from 'react-router-dom';
import { sessionActions } from '../../store';
import { useLocalization, useTranslation } from '../../LocalizationProvider';
import StartPage from '../../StartPage';
+import usePersistedState from '../../common/usePersistedState';
const useStyles = makeStyles((theme) => ({
logoContainer: {
@@ -30,8 +31,10 @@ const LoginForm = () => {
const languageList = Object.entries(languages).map((values) => ({ code: values[0], name: values[1].name }));
const [failed, setFailed] = useState(false);
- const [email, setEmail] = useState('');
+
+ const [email, setEmail] = usePersistedState('loginEmail', '');
const [password, setPassword] = useState('');
+
const registrationEnabled = useSelector((state) => (state.session.server ? state.session.server.registration : false));
const emailEnabled = useSelector((state) => (state.session.server ? state.session.server.emailEnabled : false));
@@ -77,7 +80,7 @@ const LoginForm = () => {
name="email"
value={email}
autoComplete="email"
- autoFocus
+ autoFocus={!email}
onChange={(e) => setEmail(e.target.value)}
onKeyUp={handleSpecialKey}
helperText={failed && 'Invalid username or password'}
@@ -94,6 +97,7 @@ const LoginForm = () => {
value={password}
type="password"
autoComplete="current-password"
+ autoFocus={!!email}
onChange={(e) => setPassword(e.target.value)}
onKeyUp={handleSpecialKey}
variant="filled"