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

SQForm initialErrors is never set #83

Closed
SeanGroff opened this issue Jan 22, 2021 · 0 comments
Closed

SQForm initialErrors is never set #83

SeanGroff opened this issue Jan 22, 2021 · 0 comments
Assignees
Labels
bug Something isn't working in progress

Comments

@SeanGroff
Copy link
Contributor

Issue:

When using the validationSchema prop, the errors property from Formik is initialized to an object, where each key is the name of the key from the validationSchema and the value is Required for any field in the validationSchema set to .required(). If an entry in validationSchema is NOT required, that entry is excluded from the errors object in Formik.

For example:

const validationSchema = {
  name: Yup.string().required(),
  state: Yup.string()
}

// errors object would be set to:
{
   name: 'Required'
}

// initialErrors is never set so it's set to:
{}

When calling the resetForm method from Formik, among other things this method resets the errors object to the value from initialErrors. Since initialErrors is never set, errors gets set to {}.

Any functionality that depends on the presence of errors after the form has been reset will experience unexpected behavior

@SeanGroff SeanGroff self-assigned this Jan 22, 2021
@SeanGroff SeanGroff added bug Something isn't working in progress labels Jan 22, 2021
SeanGroff pushed a commit that referenced this issue Jan 25, 2021
Fixes the submit button be disabled when it shouldn't. Fixes the reset
button to reset to the proper initial errors state. Fixes the helper
text to always be in a correct state.

✅ Closes: #59, #83, #47
SeanGroff pushed a commit that referenced this issue Jan 26, 2021
## [2.10.0](v2.9.0...v2.10.0) (2021-01-26)

### Features

* 🎸 Fixes submit button, reset button, helper text behavior ([bc55e62](bc55e62)), closes [#59](#59) [#83](#83) [#47](#47)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working in progress
Projects
None yet
Development

No branches or pull requests

1 participant