Skip to content

FormField should autovalidate only if its content was changed#56365

Closed
pedromassango wants to merge 9744 commits intoflutter:masterfrom
pedromassango:patch-1
Closed

FormField should autovalidate only if its content was changed#56365
pedromassango wants to merge 9744 commits intoflutter:masterfrom
pedromassango:patch-1

Conversation

@pedromassango
Copy link
Member

@pedromassango pedromassango commented May 5, 2020

Description

I propose to auto-validate FormField only if its content was changed since its prevents end users to see validation errors even without changing the field's content.

Related Issues

Fixes: #56363
Fixes: #18885
Fixes: #15404
Fixes: #36154
Fixes: #48876

Tests

I added the following test cases:

  • Do not auto-validate before value changes if widget.autovalidateMode (new) equals to AutovalidateMode.onUserInteraction;
  • auto-validate after value changes if widget.autovalidateMode equals to AutovalidateMode.onUserInteraction;
  • Form only validates form fields after one of the form fields changes if widget.autovalidateMode is AutovalidateMode.onUserInteraction;
  • auto-validate before value changes if autovalidate is true and widget.autovalidateMode is AutovalidateMode.always;
  • Form auto validate form fields even if none of them changes if widget.autovalidateMode is always;
    autovalidate parameter is still used if true;
  • DropdownButtonFormField passes autoValidateMode to superclass;
  • Form.reset() reset form fields and auto validation will only happen on the next user interaction if autoValidateMode is onUserInteraction;

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I signed the [CLA].
  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • 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].

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

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet