-
Notifications
You must be signed in to change notification settings - Fork 29.7k
fix: Form AutovalidateMode.onUserInteraction behavior
#120730
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
fix: Form AutovalidateMode.onUserInteraction behavior
#120730
Conversation
| for (final FormFieldState<dynamic> field in _fields) { | ||
| hasError = !field.validate() || hasError; | ||
| if (widget.autovalidateMode == AutovalidateMode.onUserInteraction) { | ||
| if (_hasInteractedByUser && field._hasInteractedByUser.value) { |
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.
Is there a documentation on what Form.autovalidateMode will interact with FormField.autovalidateMode if they are both set? If not, we should document it.
| for (final FormFieldState<dynamic> field in _fields) { | ||
| hasError = !field.validate() || hasError; | ||
| if (widget.autovalidateMode == AutovalidateMode.onUserInteraction) { | ||
| if (_hasInteractedByUser && field._hasInteractedByUser.value) { |
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.
also, should we remove _hasInteractedByUser here? It seems like _hasInteractedByUser will always be true if field._hasInteractedByUser.value is true..
|
@pedromassango Is this PR still on your radar? |
Yes |
justinmc
left a comment
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.
Related to: #125766
CC @Renzo-Olivares who's looking into that bug.
The PR looks good to me if we're on board with this behavior.
| if (widget.autovalidateMode == AutovalidateMode.onUserInteraction) { | ||
| if (_hasInteractedByUser && field._hasInteractedByUser.value) { | ||
| hasError = validateFormField(field); | ||
| } | ||
| } else { | ||
| hasError = validateFormField(field); | ||
| } |
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.
Nit: If I have the logic correct, maybe this is cleaner?
| if (widget.autovalidateMode == AutovalidateMode.onUserInteraction) { | |
| if (_hasInteractedByUser && field._hasInteractedByUser.value) { | |
| hasError = validateFormField(field); | |
| } | |
| } else { | |
| hasError = validateFormField(field); | |
| } | |
| if (widget.autovalidateMode != AutovalidateMode.onUserInteraction | |
| || (_hasInteractedByUser && field._hasInteractedByUser.value)) { | |
| hasError = validateFormField(field); | |
| } |
|
@pedromassango Hey sorry to badger you, just wondering if we should close this one for now to get it off the review queue or if it's something you expect to get back to in the near future. Obviously no rush either way. |
|
@pedromassango I'm going to close this for now, please don't hesitate to reopen it if this is something you'd like to continue working on. Thanks! |
List which issues are fixed by this PR. You must list at least one issue.
Fixes #107350
Pre-launch Checklist
///).