component prevents from triggering host form#onSubmit
See original GitHub issueVersion
react-bootstrap-typeahead@3.2.4
Steps to reproduce
<form onSubmit="() => console.log('on-submit')">
<Typeahead
labelKey="name"
multiple={multiple}
options={options}
placeholder="Choose a state..."
/>
</form>
Expected Behavior
should trigger onSubmit
handler.
Actual Behavior
does nothing
I have fixed this problem before https://github.com/ericgio/react-bootstrap-typeahead/issues/112 but it seem this bug returned again
Issue Analytics
- State:
- Created 5 years ago
- Comments:14 (12 by maintainers)
Top Results From Across the Web
React - Preventing Form Submission - Stack Overflow
In javascript you can prevent that by using an event handler and calling e.preventDefault() on button click, or form submit. e is the...
Read more >How do I trigger recordEditForm onSubmit event using ...
I was looking at workaround online and it's suggested to hide a button inside the recordEditForm and to click that using Javascript, which...
Read more >Communicating with Iframes - Medium
The first thing we need to do to establish the connection between our iframe file and its host is to trigger a message...
Read more >Bootstrap React Forms - part 2, validation and errors
This React Bootstrap form example covers validating the form fields, showing error messages, and handling the react bootstrap form submit.
Read more >How To Call Web APIs with the useEffect Hook in React
To understand why you should check if the component is mounted before setting the data, see Step 2 — Preventing Errors on Unmounted ......
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 FreeTop 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
Top GitHub Comments
@hyzhak: I know it’s not ideal, but I think the workaround above should address your use case. Assuming that’s true, I’m going to close this issue as resolved. Let me know if I’m missing something, however.
The behavior you were seeing before was unintended, if not an outright bug, so what you’re asking for is really a new feature that allows users to make arbitrary selections when hitting enter. It’s unlikely I’ll add that as a first-class piece of the API, but it should currently be possible to achieve what you’re after. For example, you could use the typeahead’s
onKeyDown
listener to submit the form when the user hits enter: