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

fix(libs/form-builder): add capacity to change the default behavior 'onChange' #102

Closed
wants to merge 13 commits into from

Conversation

fffjacquier
Copy link
Collaborator

@fffjacquier fffjacquier commented Jun 20, 2024

⚠️ Closed because the forms package is moved to the app.

We got an issue in our main project: when typing the email (as the login in register form) we check on the onChange if the email is already taken or not with a backend request (via gigya).
Once this is done, we discovered that on the next field (password), each keydown was also firing the onChange event with all the validation methods assigned from all the fields.

Description

The fix made is to use the onSubmit event instead of the onChange and pass this behavior as a parameter in order not to risk breaking all our forms.

Related Issue

Can't reproduce on this repo.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@fffjacquier fffjacquier added 🐞 bug Something isn't working Bedrock When the author is a member of the organization labels Jun 20, 2024
@fffjacquier fffjacquier self-assigned this Jun 20, 2024
@fffjacquier fffjacquier added the 🫀 Core Package updates label Jun 20, 2024
@fffjacquier fffjacquier marked this pull request as ready for review June 20, 2024 09:05
@fffjacquier fffjacquier added the 🧑‍⚖️ Tech review needed Pull Request is ready for review, let's go ! label Jun 20, 2024
@@ -35,7 +35,7 @@ export interface FormBuilderProps {
onSubmit: SubmitHandler<FieldValues>;
onNextStep?: (value: UnpackNestedValue<FieldValues>) => void;
defaultValues?: DefaultValues<FieldValues>;
behavior?: keyof ValidationMode;
behavior?: keyof ValidationMode | 'onChangeTriggerByField';
Copy link
Member

Choose a reason for hiding this comment

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

No need to add this new possible value in docs? 👀

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 72.65%. Comparing base (3565210) to head (58915c3).
Report is 1 commits behind head on master.

Files Patch % Lines
libs/form-builder/src/lib/formBuilder.tsx 20.00% 3 Missing and 1 partial ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #102      +/-   ##
==========================================
- Coverage   74.68%   72.65%   -2.03%     
==========================================
  Files          28       28              
  Lines         391      395       +4     
  Branches      125      127       +2     
==========================================
- Hits          292      287       -5     
- Misses         64       67       +3     
- Partials       35       41       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fffjacquier fffjacquier changed the title fix(): add capacity to change the default behavior 'onChange' fix(libs/form-builder): add capacity to change the default behavior 'onChange' Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bedrock When the author is a member of the organization 🐞 bug Something isn't working 🫀 Core Package updates 🧑‍⚖️ Tech review needed Pull Request is ready for review, let's go !
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants