vue-form-generator icon indicating copy to clipboard operation
vue-form-generator copied to clipboard

V3 fix simple bugs

Open muschottkey opened this issue 5 years ago • 1 comments

  • Please check if the PR fulfills these requirements
  • [x] The commit message follows our guidelines

  • [x] Tests for the changes have been added (for bug fixes / features)

  • [ ] Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Fix fieldID prop case Wrong casing where fieldID prop was passed as field-id which gets resolved as fieldId which means that inputs did not receive the id configured in the schema. Resolved this by passing the component as field-i-d which is resolved to fieldID.

Use Promise success and failure handlers for .validate method Previously, the validate() function returned a promise which would resolve() if there were no validation errors, and reject(errors) if there were errors. However, when calling this validate method, we called it as the callback of the "fields-validation-trigger" event.

When this promise is rejected because of validation errors, we do not have a .catch method to deal with the rejection. This causes it to get "stuck" and dies in the console. This is unwanted behavior.

The javascript engine will track such unhandled rejections and generate global errors with the event "unhandledrejection".

This fills the console with "errors" which aren't actual execution errors.

The solution I had here was to update the code to always use resolve. If there are errors, we resolve with the errors, if there are no errors, we resolve with undefined/null.

The solution I implemented here is to include empty functions success and failure handlers.

  • What is the current behavior? (You can also link to an open issue here)
  1. fieldID in the rendered fields is undefined.
  2. When there is a validation error, javascript errors are thrown in the console log.
  • What is the new behavior (if this is a feature change)?
  1. fieldID is no longer undefined for the fields.
  2. Validation errors from validators do not cause unhandled js errors to be thrown in the console output.
  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?) NO.

muschottkey avatar Oct 08 '19 09:10 muschottkey

Coverage Status

Coverage decreased (-0.06%) to 73.864% when pulling 67dcd4f21530b2988f9991ac2ea3bedbaae3fae4 on muschottkey:v3-fix-simple-bugs into 218bababcdb4dced2fb439d6f6644c23afbf2d16 on vue-generators:v3.

coveralls avatar Oct 08 '19 09:10 coveralls