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

initialValue is being reset on change when ResetForm is called #3428

Closed
2 of 5 tasks
ellismonva opened this issue Aug 4, 2021 · 6 comments
Closed
2 of 5 tasks

initialValue is being reset on change when ResetForm is called #3428

ellismonva opened this issue Aug 4, 2021 · 6 comments
Labels
🐛 bug Unintended behavior

Comments

@ellismonva
Copy link

ellismonva commented Aug 4, 2021

What happened?

When calling the ResetForm, such as below:
resetForm({ values: { criteria: { card_type: 1 } } });;

This changes the initial value, which is correct, but then once I change my value in my form field again in my UI (such as updating to 2), it is changing the initialValue to the current value (in this case 2). I don't want initialValue to update on change, only when I call the resetForm function.

Version

Vue.js 3.x and vee-validate 4.x

What browsers are you seeing the problem on?

  • Firefox
  • Chrome
  • Safari
  • Microsoft Edge

Relevant log output

No response

Demo link

No response

Code of Conduct

@ellismonva ellismonva changed the title Initial Value is being reset on change when ResetForm is called InitialValue is being reset on change when ResetForm is called Aug 4, 2021
@ellismonva ellismonva changed the title InitialValue is being reset on change when ResetForm is called initialValue is being reset on change when ResetForm is called Aug 4, 2021
@logaretm
Copy link
Owner

logaretm commented Aug 4, 2021

Please provide a demo on codesandbox for this issue

@logaretm logaretm added the 🤔 needs reproduction This issue requires a demo label Aug 4, 2021
@ellismonva
Copy link
Author

ellismonva commented Aug 4, 2021

Hi @logaretm

Sandbox

There are three examples here. The functionality on nonNestedInput is what we expect in output.

valueNestedInputX and valueNestedInputY are acting as incorrect and different to nonNestedInput.

Why are they acting incorrectly?

After clicking 'Reset form' and once you change the value for either valueNestedInputX or valueNestedInputY (in the UI), the initialValue for these changes to be the same as the current value (which is incorrect) - note that in the nonNestedInputMeta, this does not change when the valueNonNestedInput changes.

@logaretm logaretm added 🐛 bug Unintended behavior and removed 🤔 needs reproduction This issue requires a demo labels Aug 5, 2021
@logaretm
Copy link
Owner

logaretm commented Aug 5, 2021

Thank you for reporting this, the issue was caused by the good old reference type not being cloned before assignment which means both the current input and initial value operated on the same values.

The fix should be out in the next patch for 4.4.x and 4.5-alpha.x releases.

@ellismonva
Copy link
Author

Thanks @logaretm this is great news. I wanted to just point out something from the sandbox which may have gone unnoticed - im not sure if your fix would have addressed this..

In the first screenshot below, the initial values seem to be registered correctly, however when I click reset form, there is an additional 'input.y' added in the meta.

Screenshot 2021-08-06 at 10 12 36

Screenshot 2021-08-06 at 10 12 39

@logaretm
Copy link
Owner

logaretm commented Aug 6, 2021

When dealing with values, you cannot specify paths. So input.y won't target that field. Instead, provide the entire object like input.x in your example. So this is expected.

@ellismonva
Copy link
Author

Ok, understood. Thanks @logaretm

Mini-ghost added a commit to Mini-ghost/vorms that referenced this issue May 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants