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

FieldArray does not respond to the new array by using setFieldValue() #4153

Closed
2 of 5 tasks
rmrf1039 opened this issue Feb 21, 2023 · 3 comments
Closed
2 of 5 tasks
Labels
🐛 bug Unintended behavior

Comments

@rmrf1039
Copy link

What happened?

Hi,

I was worked around with an autocomplete function. When I use setFieldValue() to set an array of data into values, FieldArray does not respond to the new value. However, I do find a temporary solution which is using setValues(JSON.parse(JSON.stringify(values))); after all of the data replacement. The FieldArray will respond.

Object.entries(donator).forEach(([k, v]) => {
    setFieldValue(k, v instanceof Array ? Object.values(v) : v);
});

// Trigger FieldArray to responde to the new values
setValues(JSON.parse(JSON.stringify(values)));

Reproduction steps

No response

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

None

Code of Conduct

@logaretm
Copy link
Owner

Can you create a quick demo for this?

@logaretm logaretm added the 🤔 needs reproduction This issue requires a demo label Feb 21, 2023
@logaretm
Copy link
Owner

logaretm commented Mar 1, 2023

Somone posted an example in a discuss that is relevant here, they are updating the iteration value with setFieldValue.

https://stackblitz.com/edit/vue3-vite-starter-bpdpwc?file=src%2FApp.vue

Happy to take another look at this if you can provide a simple demo. Are you updating the entire array with setFieldValue or updating an item of it?

@logaretm logaretm closed this as completed Mar 1, 2023
@logaretm logaretm reopened this Mar 2, 2023
@logaretm
Copy link
Owner

logaretm commented Mar 2, 2023

Reproduced in this discussion. I'm assuming it is the same issue.

@logaretm logaretm added 🐛 bug Unintended behavior and removed 🤔 needs reproduction This issue requires a demo labels Mar 2, 2023
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