When using the Polaris form elements wrapped in a form element, the form onSubmit handler does not fire when user presses the "ENTER" when in focus of the TextField element.
This only happens when there is more than one TextField element in the form.
Here is a working example of this unexpected behavior: https://codesandbox.io/s/7o8q11r4x
Note that when a form has only one TextField element, the onSubmit handler is fired successfully.
The form onSubmit handler should be fired when the user presses "ENTER" to submit the form.
The form's onSubmit handler is never fired when there is more than one TextField element in the form.
TextField element in a form element.onSubmit handler should be fired, but it is not.Here is a working example of this issue: https://codesandbox.io/s/7o8q11r4x
Thanks for bringing this to our attention @pbojinov. I鈥榤 not quite sure what鈥檚 going on here, but I鈥檝e logged this in our internal bug tracker. We鈥檒l look into it and get back to you with what we find and/or a get a bugfix merged as soon as we can.
Turns out this is normal browser behavior when multiple fields don鈥檛 have a name attribute (or multiple fields have the same name). It should work if you provide a unique name for each field.
Thanks again for reporting. Let me know if this doesn鈥檛 resolve the issue.
For those still experiencing issues, this may be because you don't have an input/button of type "submit" somewhere in the form. If you have multiple text fields, that's required. Even if you add it and make it hidden with something like "display: none", the enter key will work.
See this Stack Overflow answer for more details: https://stackoverflow.com/questions/4196681/form-not-submitting-when-pressing-enter/4196708
Most helpful comment
For those still experiencing issues, this may be because you don't have an input/button of type "submit" somewhere in the form. If you have multiple text fields, that's required. Even if you add it and make it hidden with something like "display: none", the enter key will work.
See this Stack Overflow answer for more details: https://stackoverflow.com/questions/4196681/form-not-submitting-when-pressing-enter/4196708