-
Notifications
You must be signed in to change notification settings - Fork 0
Add enableAutomaticFormSubmission flag to prevent automatic form submission on Enter key #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add enableAutomaticFormSubmission flag to prevent automatic form submission on Enter key #2
Conversation
Co-authored-by: maurovanetti <402070+maurovanetti@users.noreply.github.com>
Co-authored-by: maurovanetti <402070+maurovanetti@users.noreply.github.com>
Co-authored-by: maurovanetti <402070+maurovanetti@users.noreply.github.com>
Co-authored-by: maurovanetti <402070+maurovanetti@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot In _SupaMagicAuthState
, _SupaPhoneAuthState
, and _SupaResetPasswordState
, you have copied and pasted a long piece of code that corresponds to the submit callback of the submit button. Refactor these code blocks into a distinct method and call it from both the places where it could be called (last field + submit button).
- Extract _signInWithMagicLink() method in SupaMagicAuth - Extract _submitForm() method in SupaPhoneAuth - Extract _updatePassword() method in SupaResetPassword - Fix use_build_context_synchronously warnings by properly checking context.mounted - Fix sort_child_properties_last warnings by placing child parameter last - Reduces code duplication and improves maintainability Co-authored-by: maurovanetti <402070+maurovanetti@users.noreply.github.com>
Refactored the duplicated form submission logic into dedicated methods:
This eliminated ~95 lines of duplicated code and fixed all analyzer warnings. Commit: 2c7d1a7 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds an enableAutomaticFormSubmission
flag to all authentication components to control whether pressing Enter on the on-screen keyboard automatically submits forms. This addresses mobile UX issues where users might accidentally submit forms when using on-screen keyboards.
- Added
enableAutomaticFormSubmission
parameter to all auth components (defaults totrue
for backward compatibility) - Refactored inline form submission logic into separate methods for better maintainability
- Updated documentation and changelog to reflect the new feature
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
lib/src/components/supa_email_auth.dart | Added flag and conditional form submission logic for email authentication |
lib/src/components/supa_phone_auth.dart | Added flag and refactored form submission into separate method |
lib/src/components/supa_magic_auth.dart | Added flag and extracted magic link submission logic |
lib/src/components/supa_reset_password.dart | Added flag and separated password update logic |
lib/src/components/supa_socials_auth.dart | Code formatting improvements |
lib/src/components/supa_verify_phone.dart | Code formatting improvements |
lib/src/utils/constants.dart | Code formatting improvements |
README.md | Added comprehensive documentation for the new feature |
CHANGELOG.md | Added entry for the new feature |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
enableAutomaticFormSubmission
flag to SupaEmailAuth constructorenableAutomaticFormSubmission
flag to SupaPhoneAuth constructorenableAutomaticFormSubmission
flag to SupaMagicAuth constructorenableAutomaticFormSubmission
flag to SupaResetPassword constructorOriginal prompt
Fixes #1
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.