Submitting form when pressing 'enter' key
See original GitHub issueHey guys
I noticed that when you use the enter key to select an option in the component (react-autosuggest), the form that holds that component gets submitted, does anyone know how to disable or change this behavior?
happening on version ^9.3.1
.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:5
Top Results From Across the Web
How to submit a form when the return key is pressed?
Every time a key is pressed, function enter() will be called. If the key pressed matches the enter key (13), then sendform() will...
Read more >The Enter Key should Submit Forms, Stop Suppressing it
When filling out a form, pressing enter in a textbox should submit the form. This is known as an implicit form submission. Despite...
Read more >Submit a form with Enter key with JavaScript/jQuery
The idea is to bind an event handler to the keyup JavaScript event using jQuery's .keyup(handler) method and use that handler to submit...
Read more >How to submit a form on Enter button using jQuery
Given an HTML form and the task is to submit the form after clicking the 'Enter' button using jQuery. To submit the form...
Read more >How To Trigger Button Click on Enter - W3Schools
Trigger a button click on keyboard "enter" with JavaScript. Trigger a Button Click on Enter. Press the "Enter" key inside the input field...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In case it helps anyone:
We managed to keep form submission on ENTER but prevent it if ENTER was used to choose a suggestion by keeping track of whether an option is selected or not via
onSuggestionHighlighted
. If an option is selected, then ENTER is prevented from submitting the form as described above.@charlesrochati I prevented submit of our form (also using redux-form) by passing an
onKeyDown
handler in to theinputProps
prop on Autosuggest: