-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Proposal: deprecate autovalidate parameter of the Form, FormField and TextFormField widget #61648
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
Proposal: deprecate autovalidate parameter of the Form, FormField and TextFormField widget #61648
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
it looks like the test in https://github.com/jocosocial/rainbowmonkey is failing, you should be able to repro using https://github.com/flutter/tests/blob/master/registry/rainbowmonkey.test you can file an issue or pr to fix it in that repo, cc @Hixie for the repo owner. |
|
Hi @chunhtai the PR was merged on https://github.com/jocosocial/rainbowmonkey but the tests here are not passing. I think this has something to do with the flutter build or rainbowmonkey's build. Also Hixie pointed something here jocosocial/rainbowmonkey#329 (comment) that may cause this. |
You will need to update the flutter/test library to point to the new ref commit. |
|
flutter/tests#43 has merged, please do a rerun or rebased and the tests should pass |
|
@chunhtai Done. |
|
looks like there are some more internal or external test that need to be migrate |
|
@chunhtai looks like another PR just landed in the Gallery repository and I think that the last commit there has my changes, is there a way to confirm that or restart this PR tests? |
I just clicked rerun, you can also trigger rerun by commit a new commit (ex, rebase your branch) |
|
Hi @pedromassango cirrus seems not happy |
|
If merging in master isn't working, it might need to have all the commits squashed, or rebase master. The failure I looked at was unrelated to the changes. |
Not sure why tests are failing too. I will |
|
@justinmc I probably need some help with this, what else I can do to make the tests to pass? |
|
@pedromassango If you squash all of your commits into 1, then rebase off of master, then force push, that should definitely update everything. Sorry that that will make you lose your history, though. I think the idea is that the first commit's SHA needs to change in order for something to get updated and allow the PR to pass. I see a docs failure that might be real, but I also see some version failures that don't make sense and probably do need the steps above to get fixed. |
99290cd to
6d1242d
Compare
|
This file may require migration as well |
|
there are also doc string error |
chunhtai
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.
LGTM
… TextFormField widget (flutter#61648)
| /// If true, form fields will validate and update their error text | ||
| /// immediately after every change. Otherwise, you must call | ||
| /// [FormState.validate] to validate. | ||
| final bool autovalidate; |
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.
Turns out this is a breaking change. The public field is removed, not deprecated.
This affects (at least) flutter_form_builder.
flutter-form-builder-ecosystem/flutter_form_builder#465
Ideally, should (with appropriate deprecated tag) put something like
bool get autovalidate => autovalidateMode != AutovalidateMode.disabled;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.
@pedromassango oops did we miss this one?
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.
Hmm. Just checked form.dart file and I don't see any reference for final bool autovalidate. We did removed this intentionally in favour of AutovalidateMode property.
Maybe this is referencing a old commit file?!
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.
bool get autovalidate => autovalidateMode != AutovalidateMode.disabled;
This is interesting and would prevent the breaking changes 🤔
@chunhtai do you think this we should put it back?
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.
@skyeskie
What are the use cases of using this Widget's property?
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.
I think we should put this one back, but we should do
autovalidateMode = autovalidateMode ?? autovalidate ? AutovalidateMode.always : AutovalidateMode.disabled
Same as what we do for other formfield
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.
Alright, I will send a PR to put it back ASAP
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.
FormField has the exact same issue (below, 363-368)
@pedromassango
I personally don't use this, but just ran across when flutter_form_builder refused to compile, specifically when it tries to access autovalidate on FormField in its FormBuilderCustomField class here.
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.
Description
This PR comes to deprecate the
autovalidateparameter of theForm,FormFieldand theTextFormFieldwidget in favor of the recently addedautovalidateModeparameter. This is a follow up of #59766.Related Issues
This does not need tests since I'm only deprecating a parameter.
Tests
I added the following tests:
Checklist
///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read [Handling breaking changes].