Skip to content
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

Form level validation state mutation #719

Merged
merged 2 commits into from
Aug 17, 2020

Conversation

Hyperkid123
Copy link
Member

part of #687

Changes

  • add state mutation after form level validation
  • synchronizes form-level and field-level validation errors and state flags

@Hyperkid123 Hyperkid123 added the State manager Form state manager packages. Will be used a state management package for the form renderer. label Aug 17, 2020
@Hyperkid123 Hyperkid123 requested a review from rvsia August 17, 2020 12:18
@Hyperkid123 Hyperkid123 mentioned this pull request Aug 17, 2020
9 tasks
@Hyperkid123 Hyperkid123 changed the base branch from master to state-manager August 17, 2020 12:23
@codecov
Copy link

codecov bot commented Aug 17, 2020

Codecov Report

Merging #719 into state-manager will increase coverage by 0.07%.
The diff coverage is 100.00%.

Impacted file tree graph

@@                Coverage Diff                @@
##           state-manager     #719      +/-   ##
=================================================
+ Coverage          93.06%   93.13%   +0.07%     
=================================================
  Files                220      220              
  Lines               3574     3613      +39     
  Branches            1133     1138       +5     
=================================================
+ Hits                3326     3365      +39     
  Misses               248      248              
Impacted Files Coverage Δ
...ckages/form-state-manager/src/utils/manager-api.ts 96.52% <100.00%> (+0.71%) ⬆️
...s/form-state-manager/src/utils/use-subscription.ts 97.77% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ee43d6c...14627f9. Read the comment docs.

@Hyperkid123 Hyperkid123 force-pushed the form-level-validation-state-mutation branch from 03fe94e to 14627f9 Compare August 17, 2020 12:25
Comment on lines +270 to +273
/**
* Fields have to be revalidated on field level to synchronize the form and field errors
*/
revalidateFields(currentInvalidFields);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we avoid this? This is not how the form currently behaves (check it here) and it brings performance issues (why to validate fields that have been already validated?)

Also, it means that active field is being validated 2x: field validation > form validation > field validation

Copy link
Member Author

Choose a reason for hiding this comment

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

It definitely can and should be. I wanted to postpone this after we have the memorize functionality implemented because that is a big part of it.

The validation will have have to run twice at some point (it does in the example as well) because the validation functions are different.

Once we have the memo we can "save" the active field revalidation by running the field level after the form level and check if it was validated in that cycle.

@rvsia rvsia merged commit fbbbcc8 into state-manager Aug 17, 2020
@Hyperkid123 Hyperkid123 deleted the form-level-validation-state-mutation branch August 17, 2020 13:32
@Hyperkid123
Copy link
Member Author

🎉 This PR is included in version 3.1.0 🎉

The release is available on

Demo can be found here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released State manager Form state manager packages. Will be used a state management package for the form renderer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants