Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SolidJS: Form reset action doesn't preventDefault like submit does. #186

Open
sid1029 opened this issue Feb 25, 2024 · 1 comment
Open
Assignees
Labels
enhancement New feature or request

Comments

@sid1029
Copy link

sid1029 commented Feb 25, 2024

I have an example here : https://stackblitz.com/edit/solidjs-templates-7pgd2x?file=src%2FApp.tsx

To observe the issue click reset.

What happens : form values disappear.
Expected behavior: Clicking reset should reset the form to its initialValues.

I was stuck on this for a while. The onReset action on a form doesn't seem to preventDefault() its event the way the submit handler does for you.

This causes the native browser behavior to override the behavior of the reset() function provided by modular-forms.

I would expect to just be able to call reset(formState) in the reset handler on a <Form> element and have the fields go back to their initialValues. But if I don't explicitly event.preventDefault() first, the browser resets the fields to blank values in the UI.
The underlying formState model maintained by modular-forms correctly reflects the initialValues after reset().

Maybe my expectation is wrong but if I'm using the <Form> element generated by modular-forms instead of the native HTML <form> element I would expect things are really handled end-to-end by the library for me.

PS: This is a great library ! I'm using this with solid-bootstrap.

@fabian-hiller fabian-hiller self-assigned this Feb 26, 2024
@fabian-hiller fabian-hiller added the enhancement New feature or request label Feb 26, 2024
@fabian-hiller
Copy link
Owner

Thank you very much! That is a good point. Unfortunately, I have less time for Modular Forms at the moment, but this is something I will consider for the future of the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants