fix: Form AutovalidateMode.onUserInteraction behavior#120730
fix: Form AutovalidateMode.onUserInteraction behavior#120730pedromassango wants to merge 1 commit intoflutter:masterfrom
AutovalidateMode.onUserInteraction behavior#120730Conversation
| 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.
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.
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.
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.
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
///).