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

[V4] The value of radio fields is kept by the form even when hidden #3963

Closed
4 of 5 tasks
anis opened this issue Oct 17, 2022 · 1 comment · Fixed by #3972
Closed
4 of 5 tasks

[V4] The value of radio fields is kept by the form even when hidden #3963

anis opened this issue Oct 17, 2022 · 1 comment · Fixed by #3972
Labels
🐛 bug Unintended behavior

Comments

@anis
Copy link

anis commented Oct 17, 2022

What happened?

The value of a radio field is kept on unmount, even though the option keepValues is set to false.
I expect a Form to not keep the value of a hidden radio field.

Reproduction steps

  1. Create a Form with a radio Field:
<Form>
  <Field type="radio" name="demo" value="1" />
  <Field type="radio" name="demo" value="2" />
</Form>
  1. After selecting one of the values, hide the Field somehow (by clicking on a button for instance):
<Field v-if="showField" type="radio" ... />
...
<button @click="showField = false" />
  1. When the Field is unmounted, see how its value is still kept by the Form

Using the demo link you may follow the steps below:

  1. Click on whatever radio button you want ("Yes" or "No")
  2. Type in some text in the textfield
  3. See how the values of both question1 and question2 are displayed
  4. Click on the "Hide the questions" button which hides both fields
  5. See how the value of question2 disappears, but question1 is kept even though the field has been unmounted

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://codesandbox.io/embed/vigorous-bohr-dh6uyo?fontsize=14&hidenavigation=1&theme=dark

Code of Conduct

@anis anis changed the title [V4] [V4] The value of radio fields is kept by the form even when hidden Oct 17, 2022
@logaretm logaretm added the 🐛 bug Unintended behavior label Oct 18, 2022
@logaretm
Copy link
Owner

Thank you for reporting this, I found the issue and will tag a new release shortly.

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

Successfully merging a pull request may close this issue.

2 participants