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

The meta.dirty value always true when you use initialValues parameter in useForm() #4697

Open
2 of 5 tasks
Alekenzy opened this issue Mar 12, 2024 · 0 comments
Open
2 of 5 tasks

Comments

@Alekenzy
Copy link

Alekenzy commented Mar 12, 2024

What happened?

For example, I have this form:

interface EditVersionModalForm {
  name: string
  name2: string
  name3: string
}

const useFormOptions = {
  validationSchema: {
    name: requiredField,
  },
  initialValues: {
    name: props.tariff.name,
    name2: props.tariff.name2,
    name3: props.tariff.name3,
  },
}

const { defineField, handleSubmit, errors, meta, handleReset } =
  useForm<EditVersionModalForm>(useFormOptions)

In this case, I am trying to disable the submit button, when values are didn't change at all. But I get always meta.dirty value as true

I think useForm considers initialValues as "updated values". But if we will think from UX side, it seems should be false, when you give initial values. And only set to true, when initial values are changed.

Reproduction steps

  1. Create form using useForm() composable.
  2. Set initialValues parameter
  3. Always get a meta.dirty value as true

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

I can't. But I think I explained well

Code of Conduct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant