JedWatson / JedWatson/react-select
Enter key submitting form when menu open but showing no options
- Dominant language
- TypeScript
- Stars
- 28k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
Within a <form onSubmit={}> form that uses an onSubmit handler and a regular old <button type="submit">, the enter key is submitting the form despite the react-select menu being open. This seems to happen when there are no options to display in the list.

Have created a quick demo here:
https://codesandbox.io/s/react-codesandboxer-example-i6bwn
Steps to reproduce:
- Type any non-existent colour in the select and ensure you are seeing the "No options" message.
- Hit enter, see the alert that the form has been submitted.
Is this intended behaviour?
Thanks :)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue in the linked CodeSandbox: type a value with no matching options and press Enter inside the form. Review open pull request #3945 for the current direction, then confirm the intended behavior for Enter when the menu shows “No options”; done means that behavior is resolved and verified without unintended form submission.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100