Respect per-field autovalidateMode priority#182752
Respect per-field autovalidateMode priority#182752Mairramer wants to merge 8 commits intoflutter:masterfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors form validation logic to prioritize FormField.autovalidateMode over the parent Form's setting, which is a great enhancement for flexibility. The changes centralize validation logic within FormFieldState, leading to cleaner code. The tests have been updated appropriately to cover this new behavior. I have a couple of suggestions to improve documentation accuracy and code clarity.
… of useFieldAutovalidateMode
justinmc
left a comment
There was a problem hiding this comment.
LGTM to kick off the Google tests.
|
Welp it seems to have failed Google tests. I see a form field that used to be focused and showing a hint (min/max values) and a disabled button, but now the field is not focused and has no hint, and the button is enabled. I believe the relevant FormField is a TextFormField with Or is there any other reason why this PR would cause that failure? |
I tried to reproduce the scenario based on your description, but I couldn’t reproduce it locally. It’s possible I missed something, but I’m not sure what it might be. Edit: It might be related to the fix for #107350. |
Implemented a hierarchical validation logic:
FormField.autovalidateModenow takes precedence over the parentFormsettings. If the field-level mode is unspecified, it inherits the form-level configuration, with a final fallback toAutovalidateMode.disabled. Also fixesAutovalidateMode.onUserInteractionvalidates without user interaction.Fixes #125766
Fixes #107350
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.