inertia icon indicating copy to clipboard operation
inertia copied to clipboard

fix nested value in defaults getting override

Open eslym opened this issue 3 years ago • 0 comments

The nested value in defaults will be override when the data update because of the sharing same instance with data.

let form = useForm({
    name: '',
    address: {
        line1: "",
        line2: "",
        city: "",
        state: "",
        postcode: "",
    }
});
console.log($form.address === $form.defaults.address); // showing they are same instance
$form.address.city = "Kuala Lumpur";
console.log($form.defaults.address.city); // => "Kuala Lumpur", while the expected value is empty string
console.log($form.isDirty); // => false, because $form.address and $form.defaults.address are same value so its not "dirty"

eslym avatar Jun 30 '22 07:06 eslym