From 98599a7d24edc4644861ef7c2de51b86f4eb1164 Mon Sep 17 00:00:00 2001 From: gotjoshua Date: Mon, 26 Apr 2021 14:58:59 +0100 Subject: [PATCH] closes #181 unlock via enter key (#187) * closes #181 unlock via enter key * style coherence with semantic fx naming --- src/pages/LoginPage.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/pages/LoginPage.js b/src/pages/LoginPage.js index 6842549..cf0716b 100644 --- a/src/pages/LoginPage.js +++ b/src/pages/LoginPage.js @@ -211,13 +211,22 @@ function LoginForm() { const [stayLoggedIn, setStayLoggedIn] = useState(false); const callAsync = useCallAsync(); - function submit() { + const submit = () => { callAsync(loadMnemonicAndSeed(password, stayLoggedIn), { progressMessage: 'Unlocking wallet...', 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 ( @@ -232,13 +241,14 @@ function LoginForm() { type="password" autoComplete="current-password" value={password} - onChange={(e) => setPassword(e.target.value)} + onChange={setPasswordOnChange} + onKeyDown={submitOnEnter} /> setStayLoggedIn(e.target.checked)} + onChange={toggleStayLoggedIn} /> } label="Keep wallet unlocked"