-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Type error on (form) values and handleSubmit not correct when using a computed as initial values #4402
Comments
Reactive initial values will be deprecated, as they do not have much use and the recommended way to set initial values is with |
@logaretm |
You can reset that single field with resetForm({ values: { thatField: 'value' })}); Let me know if that doesn't work. I believe |
@logaretm also, this is a breaking change, since now passing a computed into initialValues leads to a stack overflow https://codesandbox.io/p/sandbox/basic-example-composition-api-forked-fw346y?file=%2Fpackage.json%3A9%2C5 |
this sets all other fields to undefined
this breaks meta.dirty of the form |
And this approach where we change the value of initialValues and rely on the Before: Now: And if that's the case, why does this code even exist anymore? https://github.com/logaretm/vee-validate/blob/main/packages/vee-validate/src/useForm.ts#L1211 There's no way to call |
@logaretm should I open new issues for the call stack overflow and the inability to set an initial value of a single field? |
For the call stack issue, the initial values are no longer allowed to be reactive. But we can add a fallback to unref it so it doesn't crash at least. but the types will reject it as intended. For the resetField, that should work, so yes that might be a bug. So yes, feel free to create a couple of issues for those and I will tackle them. |
What happened?
The types for the values returned from useForm and the fomdata in the handleSubmit closure are not correct when u use a computed as initialValue
Reproduction steps
vue-tsc --noEmit {enter}
Version
Vue.js 3.x and vee-validate 4.x
What browsers are you seeing the problem on?
Relevant log output
The text was updated successfully, but these errors were encountered: