closes #181 unlock via enter key (#187)

* closes #181 unlock via enter key

* style coherence with semantic fx naming
This commit is contained in:
gotjoshua 2021-04-26 14:58:59 +01:00 committed by GitHub
parent 850620b77b
commit 98599a7d24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 4 deletions

View File

@ -211,12 +211,21 @@ function LoginForm() {
const [stayLoggedIn, setStayLoggedIn] = useState(false); const [stayLoggedIn, setStayLoggedIn] = useState(false);
const callAsync = useCallAsync(); const callAsync = useCallAsync();
function submit() { const submit = () => {
callAsync(loadMnemonicAndSeed(password, stayLoggedIn), { callAsync(loadMnemonicAndSeed(password, stayLoggedIn), {
progressMessage: 'Unlocking wallet...', progressMessage: 'Unlocking wallet...',
successMessage: 'Wallet unlocked', successMessage: 'Wallet unlocked',
}); });
} }
const submitOnEnter = (e) => {
if (e.code === "Enter" || e.code === "NumpadEnter") {
e.preventDefault();
e.stopPropagation();
submit();
}
}
const setPasswordOnChange = (e) => setPassword(e.target.value);
const toggleStayLoggedIn = (e) => setStayLoggedIn(e.target.checked);
return ( return (
<Card> <Card>
@ -232,13 +241,14 @@ function LoginForm() {
type="password" type="password"
autoComplete="current-password" autoComplete="current-password"
value={password} value={password}
onChange={(e) => setPassword(e.target.value)} onChange={setPasswordOnChange}
onKeyDown={submitOnEnter}
/> />
<FormControlLabel <FormControlLabel
control={ control={
<Checkbox <Checkbox
checked={stayLoggedIn} checked={stayLoggedIn}
onChange={(e) => setStayLoggedIn(e.target.checked)} onChange={toggleStayLoggedIn}
/> />
} }
label="Keep wallet unlocked" label="Keep wallet unlocked"