Skip to content

Conversation

@pedromassango
Copy link
Member

@pedromassango pedromassango commented Jul 16, 2020

Description

This PR comes to deprecate the autovalidate parameter of the Form, FormField and the TextFormField widget in favor of the recently added autovalidateMode parameter. 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

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I signed the [CLA].
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read [Handling breaking changes].

@fluttergithubbot
Copy link
Contributor

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.

@fluttergithubbot fluttergithubbot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Jul 16, 2020
@pedromassango pedromassango changed the title Proposal: deprecate autovalidate parameter of the Form, FormField and TextFormField Proposal: deprecate autovalidate parameter of the Form, FormField and TextFormField widget Jul 16, 2020
@pedromassango
Copy link
Member Author

@chunhtai this is the PR to deprecate the autovalidate parameter as we talked on #59766.

@chunhtai
Copy link
Contributor

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.

@pedromassango
Copy link
Member Author

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.

@chunhtai
Copy link
Contributor

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.
https://github.com/flutter/tests/blob/master/registry/rainbowmonkey.test

@chunhtai
Copy link
Contributor

flutter/tests#43 has merged, please do a rerun or rebased and the tests should pass

@pedromassango
Copy link
Member Author

@chunhtai Done.

@chunhtai
Copy link
Contributor

looks like there are some more internal or external test that need to be migrate

@pedromassango
Copy link
Member Author

@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?

@chunhtai
Copy link
Contributor

chunhtai commented Aug 3, 2020

@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)

@chunhtai
Copy link
Contributor

Hi @pedromassango cirrus seems not happy

@justinmc
Copy link
Contributor

justinmc commented Aug 24, 2020

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.

@pedromassango
Copy link
Member Author

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 rebase master and see how it goes.

@pedromassango
Copy link
Member Author

@justinmc I probably need some help with this, what else I can do to make the tests to pass?

@justinmc
Copy link
Contributor

@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.

@justinmc justinmc reopened this Sep 1, 2020
@chunhtai
Copy link
Contributor

chunhtai commented Sep 1, 2020

This file may require migration as well

dev/integration_tests/flutter_gallery/lib/demo/material/text_form_field_demo.dart:183:11 • deprecated_member_use

@chunhtai
Copy link
Contributor

chunhtai commented Sep 1, 2020

there are also doc string error

dartdoc:stderr:   error: unresolved doc reference [autovalidate]
dartdoc:stderr:     from widgets.Form.autovalidateMode: (file:///b/s/w/ir/k/flutter/packages/flutter/lib/src/widgets/form.dart:144:26)
dartdoc:stderr:     in documentation inherited from widgets.Form.autovalidateMode: (file:///b/s/w/ir/k/flutter/packages/flutter/lib/src/widgets/form.dart:144:26)
dartdoc:stderr:   error: unresolved doc reference [autovalidate]
dartdoc:stderr:     from widgets.FormField.autovalidateMode: (file:///b/s/w/ir/k/flutter/packages/flutter/lib/src/widgets/form.dart:388:26)
dartdoc:stderr:     in documentation inherited from widgets.FormField.autovalidateMode: (file:///b/s/w/ir/k/flutter/packages/flutter/lib/src/widgets/form.dart:388:26)

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fluttergithubbot fluttergithubbot merged commit 7fdd921 into flutter:master Sep 2, 2020
mingwandroid pushed a commit to mingwandroid/flutter that referenced this pull request Sep 6, 2020
/// 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;

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;

Copy link
Contributor

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?

Copy link
Member Author

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?!

Copy link
Member Author

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?

Copy link
Member Author

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?

Copy link
Contributor

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

Copy link
Member Author

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR is: #66267

@chunhtai I think we should add it back on formField widget too, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants