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

Form isDirty always false after setting defaults #2109

Open
Soletiq opened this issue Nov 27, 2024 · 3 comments · May be fixed by #2112
Open

Form isDirty always false after setting defaults #2109

Soletiq opened this issue Nov 27, 2024 · 3 comments · May be fixed by #2112

Comments

@Soletiq
Copy link

Soletiq commented Nov 27, 2024

Versions:

  • @inertiajs/vue3 version: 1.0.14

Describe the problem:

IsDirty remains false after pushing values to an array.

Steps to reproduce:

Set up a form:

const form = useForm({
    foo: []
})

Set the values as default:

form.defaults()

Push to the array:

console.log('before push', form.isDirty) // false
form.foo.push(1)
console.log('after push', form.isDirty) // false?
@Soletiq Soletiq changed the title IsDirty always false after setting defaults Form isDirty always false after setting defaults Nov 27, 2024
@Dsaquel Dsaquel linked a pull request Nov 30, 2024 that will close this issue
@Dsaquel
Copy link

Dsaquel commented Nov 30, 2024

Thanks for reporting

@vitali-bc
Copy link

on react too!

@Dsaquel
Copy link

Dsaquel commented Dec 13, 2024

I tested and it seems like react work well. On react form.isDirty is just fired late but it get update.
On vue it just never get update and that because of vue's proxy passed to defaults:

defaults = this.data()

@vitali-bc try this

  const form = useForm({
    foo: []
  })

  useEffect(() => {
    form.setDefaults()
    form.setData({ foo: [...form.data.foo, 1] })
  }, []);
  useEffect(() => {
  console.log(form.isDirty)
}, [form.isDirty])

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

Successfully merging a pull request may close this issue.

3 participants