laravel/precognition

form reset() w/o params doens't reset old values

makroxyz opened this issue · 3 comments

Laravel Precognition Plugin Version

0.5.2

Laravel Version

10.29

Plugin

Vue w/ Inertia

Description

when call form.reset() without names parameters validator doesn't reset old values.

core/validator.js

reset(...names) {
    if (names.length === 0) {
        setTouched([]) // <--- oldData is not reset
    } else {
        const newTouched = [...touched]

        names.forEach(name => {
            if (newTouched.includes(name)) {
                newTouched.splice(newTouched.indexOf(name), 1)
            }

            set(oldData, name, get(initialData, name))
        })

        setTouched(newTouched)
    }

    return form

next validation request doesn't start.

works if I reset with parameters

Steps To Reproduce

form.defaults({
  first_name: '',
  last_name: ''
}).reset()

form.touch('first_name', 'last_name')
form.validate() // <-- make request

form.reset()
form.touch('first_name', 'last_name')
form.validate() // <-- no request

form.reset('first_name', 'last_name')
form.touch('first_name', 'last_name')
form.validate() // <-- make request

Hey there,

Can you first please try one of the support channels below? If you can actually identify this as a bug, feel free to open up a new issue with a link to the original one and we'll gladly help you out.

Thanks!

@driesvints could be a bug... what do I ask for in channels?

Ask in a support channel if someone can confirm this bug.