Skip to content

[v4.5] Individual checkboxes ignore initial value on formReset() #3551

Description

@gurudusty

What happened?

When using an individual checkbox (non-array) with a default value of true, the resetForm() method will always set the checkbox to the unchecked state.

This seems to be true no matter how the resetForm method is called. E.g. reset inside a <Form> component, resetForm({values:{checkField:true}}, resetForm().

Looking at the resetForm method, it looks like setValues/initialValues (Here or Here) sets the field to true as expected.
But when it calls resetField in applyFieldMutation (Here) it essentially toggles the field back off.

This issue seems to have been introduced in version 4.5.0.

Reproduction steps

  1. Create a form with one or more single value checkboxes with an initial value of true.
  2. Reset the form. Either passing a true value or empty (to use old initial values).

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://codepen.io/dusion/pen/zYdooKj

Code of Conduct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions