From dc1b8df71c9b404873fe2b22e3a2c809e3b696db Mon Sep 17 00:00:00 2001 From: Sakamoto-Shun Date: Thu, 24 Apr 2025 09:16:54 +0900 Subject: [PATCH] feat: add autofocus option to SupaEmailAuth --- lib/src/components/supa_email_auth.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/components/supa_email_auth.dart b/lib/src/components/supa_email_auth.dart index 1602677..0fd2396 100644 --- a/lib/src/components/supa_email_auth.dart +++ b/lib/src/components/supa_email_auth.dart @@ -159,6 +159,9 @@ typedef MetadataController = Object; /// ``` /// {@endtemplate} class SupaEmailAuth extends StatefulWidget { + /// Whether the email field should automatically focus when the form is shown + final bool autofocus; + /// The URL to redirect the user to when clicking on the link on the /// confirmation link after signing up. final String? redirectTo; @@ -220,6 +223,7 @@ class SupaEmailAuth extends StatefulWidget { /// {@macro supa_email_auth} const SupaEmailAuth({ super.key, + this.autofocus = true, this.redirectTo, this.resetPasswordRedirectTo, this.passwordValidator, @@ -298,7 +302,7 @@ class _SupaEmailAuthState extends State { keyboardType: TextInputType.emailAddress, autofillHints: const [AutofillHints.email], autovalidateMode: AutovalidateMode.onUserInteraction, - autofocus: true, + autofocus: widget.autofocus, focusNode: _emailFocusNode, textInputAction: _isRecoveringPassword ? TextInputAction.done