From 22aa26fd052625cccf4fe36d5f3ed395aea81726 Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Sat, 6 Jun 2026 10:15:29 -0400 Subject: [PATCH] fix keyboard navigation of forms Including submit with keyboard, and not defocusing on submit of a form --- lib/pages/login_page.dart | 3 +++ lib/pages/verify_page.dart | 37 ++++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart index 4969287..5c9d53d 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -80,6 +80,9 @@ class LoginPage extends HookConsumerWidget { validator: requiredValidator, controller: password, obscureText: true, + onFieldSubmitted: (_) => tryLogin(), + // Don't defocus on submit + onEditingComplete: () {}, ), ], ), diff --git a/lib/pages/verify_page.dart b/lib/pages/verify_page.dart index a2089e3..bf5c9f3 100644 --- a/lib/pages/verify_page.dart +++ b/lib/pages/verify_page.dart @@ -15,6 +15,22 @@ class VerifyPage extends HookConsumerWidget { final inputError = useState(null); final formKey = useRef(GlobalKey()); + Future verify() async { + isLoading.value = true; + + try { + if (formKey.value.currentState?.validate() != true) { + return; + } + + inputError.value = await ref + .watch(ClientController.provider.notifier) + .verify(passphraseController.text); + } finally { + isLoading.value = false; + } + } + return Scaffold( appBar: Appbar(), body: AlertDialog( @@ -40,29 +56,16 @@ class VerifyPage extends HookConsumerWidget { label: Text("Recovery Key or Passphrase"), errorText: inputError.value, ), + onFieldSubmitted: (_) => verify(), + // Don't defocus on submit + onEditingComplete: () {}, ), ], ), ), actions: [ TextButton( - onPressed: isLoading.value - ? null - : () async { - isLoading.value = true; - - try { - if (formKey.value.currentState?.validate() != true) { - return; - } - - inputError.value = await ref - .watch(ClientController.provider.notifier) - .verify(passphraseController.text); - } finally { - isLoading.value = false; - } - }, + onPressed: isLoading.value ? null : verify, child: Text("Verify"), ), ],