Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event swallowed when pressing Enter #212

Closed
kembuco opened this issue May 27, 2015 · 4 comments
Closed

Event swallowed when pressing Enter #212

kembuco opened this issue May 27, 2015 · 4 comments

Comments

@kembuco
Copy link
Contributor

kembuco commented May 27, 2015

Currently pressing enter when the select list isn't open causes the keypress event to be swallowed. Preventing the default behavior of enter when the select list is open seems like the right behavior. However, it prevents things like form submission if the list is closed.

I can submit a pull request with a fix for this. Basically, it just adds an else clause that returns if the select list isn't open.

kembuco added a commit to kembuco/react-select that referenced this issue May 27, 2015
dcousens added a commit that referenced this issue May 28, 2015
#212. Fixes issue with event being swallowed on Enter keydown
@dcousens
Copy link
Collaborator

dcousens commented May 28, 2015

Fixed in #212 #213

@sstern6
Copy link

sstern6 commented Dec 22, 2017

This seems to be re occurring in version 1.1.0. On a form with an onSubmit, the enter causes the dropdown to open, and the onSubmit wont fire.

Thanks

@sstern6
Copy link

sstern6 commented Jan 2, 2018

@dcousens youre right, this way fixed in #212, but for some reason on master it was changed. https://github.com/JedWatson/react-select/blob/master/src/Select.js#L454.

@jnachtigall
Copy link
Contributor

@dcousens Looks like a regression. Could this be reopened?

but for some reason on master it was changed. https://github.com/JedWatson/react-select/blob/master/src/Select.js#L454.

@sstern6 this link point to the wrong line now, here's one with a fixed git hash:

react-select/src/Select.js

Lines 487 to 494 in 7bc9363

case 13: // enter
event.preventDefault();
event.stopPropagation();
if (this.state.isOpen) {
this.selectFocusedOption();
} else {
this.focusNextOption();
}

<Enter> is always prevented, so the form is never submitted on <Enter>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants