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 defaults() then reset() doesn't work as expected #1862

Open
fufaldinav opened this issue Apr 18, 2024 · 0 comments
Open

Form defaults() then reset() doesn't work as expected #1862

fufaldinav opened this issue Apr 18, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@fufaldinav
Copy link

fufaldinav commented Apr 18, 2024

Version:

  • @inertiajs/vue3 version: 1.0.6

Describe the problem:

The form does not reset isDirty state after calling defaults() and then calling reset()
This behavior is observed if there are only primitive values in the form
I assume that watcher doesn't see changes and does not change the IsDirty state

watch(
  form,
  (newValue) => {
    form.isDirty = !isEqual(form.data(), defaults)
    if (rememberKey) {
      router.remember(cloneDeep(newValue.__remember()), rememberKey)
    }
  },
  { immediate: true, deep: true },
)

Steps to reproduce:

Create a form as in the playground:

const form = useForm('NewUser', {
  name: '',
  company: '',
  role: '',
})

Try to change some value

image

Next, call defaults() and reset(), isDirty will not change its state

REC-20240418225231.mp4
@fufaldinav fufaldinav changed the title Form defaults() when reset() doesn't work as expected Form defaults() then reset() doesn't work as expected Apr 18, 2024
@driesvints driesvints added the bug Something isn't working label Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants