modular-forms icon indicating copy to clipboard operation
modular-forms copied to clipboard

[Types] Form onSubmit is mandatory on every package after latest release

Open plushdohn opened this issue 1 year ago • 4 comments

The PR that fixed #219 inadvertently seems to have made the onSubmit prop in the Form component mandatory on every package.

Here's a repro with Solid https://stackblitz.com/edit/modular-forms-solid-phgga2?file=src%2Froutes%2Flogin.tsx

Screenshot 2024-08-09 at 18 06 44

I was also able to repro on the Preact package so I guess it's the same for all (since the fix for #219 was applied everywhere)

The bug goes away when reverting to 0.22.0 instead of using the latest 0.22.1.

plushdohn avatar Aug 09 '24 16:08 plushdohn

@fabian-hiller I know you're busy on Valibot, I'd have made a PR directly but I'm not sure how you want to tackle this since it's on every package. Is making onSubmit optional on the forms props enough? I don't know if there's a reason why it's not optional right now. In that case I'll make a PR asap.

plushdohn avatar Aug 09 '24 16:08 plushdohn

Does a form without onSubmit make sense? How do you process the submission?

fabian-hiller avatar Aug 10 '24 10:08 fabian-hiller

Does a form without onSubmit make sense?

This is the case for every <form> element that gets enhanced implicitly by a framework. In Next.js, Remix and Solidstart you don't use onSubmit because they work with the framework's action concept instead.

I like that modular forms does it internally (which allows progressive enhancement), but a user from the outside determines the actual behaviour of the form via the action they provide to it (in both Next.js and SolidStart).

I know #3 is sort of related to this and that's a work in progress, but still I was using modular forms without a problem until I updated to 0.22.1

plushdohn avatar Aug 10 '24 10:08 plushdohn

I understand. I can make it optional. In general I would like to rewrite everything to make it better and offer optimized solutions for the actions feature of every framework, but at the moment I do not have time for this.

fabian-hiller avatar Aug 10 '24 17:08 fabian-hiller

A new version is available

fabian-hiller avatar Sep 06 '24 20:09 fabian-hiller