final-form / final-form-focus

🏁 Final Form "decorator" that will attempt to apply focus to the first field with an error upon an attempted form submission
MIT License
83 stars 15 forks source link

Is it possible to use final-form-focus without using <form> tag? #15

Open marrkeri opened 5 years ago

marrkeri commented 5 years ago

Check this demo: https://codesandbox.io/s/react-final-form-focus-on-first-error-ib23b

If you avoid <form> tag and you use just <button onClick={form.submit} disabled={submitting}>Submit</button>, validation is provided but focus is not there.

Problem with <form onSubmit={handleSubmit} /> is that, that even Enter on textbox will trigger it or even worse every other button without specifying type="". It would be also helpful to have it without <form> tag

marrkeri commented 5 years ago

In this link I have been fighting with with onSubmit on <form> so at least for now it will help to others https://stackoverflow.com/questions/58560978/form-onsubmit-handlesubmit-is-triggered-through-any-button-which-has-type-sub/58561557#58561557