fix keyboard navigation of forms

Including submit with keyboard, and not defocusing on submit of a form
This commit is contained in:
Henry Hiles 2026-06-06 10:15:29 -04:00
commit 22aa26fd05
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
2 changed files with 23 additions and 17 deletions

View file

@ -80,6 +80,9 @@ class LoginPage extends HookConsumerWidget {
validator: requiredValidator,
controller: password,
obscureText: true,
onFieldSubmitted: (_) => tryLogin(),
// Don't defocus on submit
onEditingComplete: () {},
),
],
),

View file

@ -15,6 +15,22 @@ class VerifyPage extends HookConsumerWidget {
final inputError = useState<String?>(null);
final formKey = useRef(GlobalKey<FormState>());
Future<void> 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"),
),
],