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
2.02k stars 105 forks source link

remix-utils/honeypot is not working anymore #770

Closed davidesigner closed 1 month ago

davidesigner commented 2 months ago

Describe the bug and the expected behavior

When you use the Honeypot from remix-utils (as explain in the documentation: with HoneypotProvider and HoneypotInputs), sometimes, the input from__confirm value is missing in the formData (while I see a value in the Provider if I add a console.log). Sometimes, it's working well... In e2e tests, the problem is always here on my side.

Maybe it's because there's no more key added to the input in the last version?

N.B. no problem in v1.1.5.

Conform version

v1.2.1

Steps to Reproduce the Bug or Issue

  1. Install the epic stack starter project: https://github.com/epicweb-dev/epic-stack
  2. Update conform to v1.2.1.
  3. Run e2e tests → broken.

What browsers are you seeing the problem on?

Chrome, Others

Screenshots or Videos

Screenshot 2024-09-15 at 19 38 09

Additional context

Do you have a solution to this problem? Ideally, I don't want to have to set defaultValue for every form that contains <HoneypotInputs />.

edmundhung commented 2 months ago

Thanks for the report. I wish I realize this earlier. This is definitely not an uncommon case so we will need to address this as soon as possible.

A few solutions I have in mind right now:

  1. Add an option to opt out from been managed by conform

This is becoming a breaking change and I hate it.

  1. Add a data attribute to opt-in instead

This can be set with the getInputProps so it won't be a breaking change. But I hate it too because it means the minimal setup is not minimal anymore.

  1. Automatic opt-in based on the initial value

Conform will only opt in for auto value update if the initial value matches the settings in the useForm hook. This should solve the issue you had but it adds an assumption that the initial value is always set to something on render. If there are any asynchronous works involved and the input has no initial value at first, conform will opt it in since it consider the initial values matches.😬

edmundhung commented 2 months ago

I have put up a fix on #775. Can you give the pre-release a try and let me know if you run into any issues? Thanks.

mxp-qk commented 2 months ago

I add the same issue with CSRF token (via remix-utils) being removed since 1.2.0, I tried with the #775 and it works again for me

edmundhung commented 2 months ago

I'm sorry for the trouble. I've concluded that it's best to revert the relevant changes, and I've just published v1.2.2.

davidesigner commented 1 month ago

@edmundhung, 1.2.2 fixed this problem but we should maybe reopen these issues?