edmundhung / conform

A type-safe form validation library utilizing web fundamentals to progressively enhance HTML Forms with full support for server frameworks like Remix and Next.js.
https://conform.guide
MIT License
1.94k stars 105 forks source link

When form.insert is called with a object as the default value it will submit the form after the second time it is called #800

Open daniel-a-marshall opened 3 days ago

daniel-a-marshall commented 3 days ago

Describe the bug and the expected behavior

An issue happens when inserting fields into a field list. This specifically happens when supplying a default value to the form.insert function. More specifically it seems to have a problem when the default value is an object. I can make it work if the default value is a string or number. When you call the form.insert with an object as the default value the first time it works fine. The second time it will submit the form. I have created a minimal reproduction here on stackblitz. I'm sure I could be doing something wrong but I just don't know what it could be.

Conform version

v1.2.1

Steps to Reproduce the Bug or Issue

1 - Click add once and a new hacker. 1 - Click add again and the form submission will be sent.

What browsers are you seeing the problem on?

Chrome

Screenshots or Videos

No response

Additional context

No response

Pouet-- commented 3 days ago

I am using version 1.1.5 and it works, so it is a bug(?) introduced by a newer version. It seems to work correctly if you upgrade to v1.2.2.

daniel-a-marshall commented 3 days ago

@Pouet-- That does work and I should have checked that. The reason I went back to 1.2.1 from 1.2.2 is that I'm still getting the react warning about spreading the key. I can try to work around that for now.