Implicit submission on forms #3252
-
Are forms with a single text input expected to support implicit submission? That is, when the input field is focused, should hitting enter invoke the primary button (like submit), or should a user have to navigate to the button in order be able to click enter and submit? Example: should hitting enter in this state (input is focused) activate the call button? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @marcdevens Absolutely! That would be our recommended approach as it's the most common and expected behaviour. Our suite of applications are very mixed in their different approaches though, so we aren't enforcing anything on anyone, in favour of teams making explicit choices. We'd love every form to do this but understand a lot of old and legacy pages have limitations. We think every form should be wrapped in a Form which provides the necessary HTML element. Form actions should be placed in the form itself. Here we require you to explicitly set the button type to be All that is left then is adding a onSubmit event handler to the form where you can process the form data or do what ever you need to do when the user hits the enter key and submits the form. Hope that helps! |
Beta Was this translation helpful? Give feedback.
Hi @marcdevens
Absolutely! That would be our recommended approach as it's the most common and expected behaviour.
Our suite of applications are very mixed in their different approaches though, so we aren't enforcing anything on anyone, in favour of teams making explicit choices. We'd love every form to do this but understand a lot of old and legacy pages have limitations.
We think every form should be wrapped in a Form which provides the necessary HTML element. Form actions should be placed in the form itself. Here we require you to explicitly set the button type to be
submit
on theButton
component.All that is left then is adding a onSubmit event handler to the form where you can proces…