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

resetForm does not completely reset array when used with useFieldArray #3934

Closed
2 of 5 tasks
olivervorasai opened this issue Sep 19, 2022 · 5 comments
Closed
2 of 5 tasks
Labels
🐛 bug Unintended behavior

Comments

@olivervorasai
Copy link

What happened?

When resetting a form via resetForm, objects that were added to an array via useFieldArray push are not completely removed. They are removed if resetForm is run twice.

Reproduction steps

  1. Open the linked minimal reproduction.
  2. Click the Add button twice.
  3. Click the resetForm button once.

Expected values state:

{
  "links": [
    {
      "id": 1,
      "url": "https://github.com/logaretm"
    }
  ]
}

Actual values state:

{
  "links": [
    {
      "id": 1,
      "url": "https://github.com/logaretm"
    },
    {}
  ]
}

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

https://stackblitz.com/edit/vitejs-vite-qwtv7u?file=src/App.vue

Code of Conduct

@olivervorasai olivervorasai changed the title resetForm does not completely reset array of objects when used with useFieldArray resetForm does not completely reset array when used with useFieldArray Sep 19, 2022
@olivervorasai
Copy link
Author

Here is another example with strings instead of objects: https://stackblitz.com/edit/vitejs-vite-fprg25?file=src/App.vue.

  1. Open the linked minimal reproduction.
  2. Click the Add button twice.
  3. Click the resetForm button once.

Expected values state:

{
  "links": [
    "first string",
  ]
}

Actual values state:

{
  "links": [
    "first string",
    null
  ]
}

@logaretm logaretm added the 🐛 bug Unintended behavior label Sep 19, 2022
@logaretm
Copy link
Owner

Thanks for reporting this. Found the issue and will tag a release shortly.

@CraxTrader
Copy link

Thanks for reporting this. Found the issue and will tag a release shortly.

resetform celar all to be null... reset should be return to initial model value... hope could be fixed as soon

@logaretm
Copy link
Owner

@CraxTrader Should be out in 4.6.9 already

@nasirDoe
Copy link

nasirDoe commented Mar 8, 2023

is issue fixed ? i still get the error. Can't reset to empty array

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

4 participants