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

Escape key should only close Dropdown #14722

Merged
merged 1 commit into from
Oct 3, 2014
Merged

Escape key should only close Dropdown #14722

merged 1 commit into from
Oct 3, 2014

Conversation

fat
Copy link
Member

@fat fat commented Oct 3, 2014

fixes #14646

@hnrch02
Copy link
Collaborator

hnrch02 commented Oct 3, 2014

#14646 (comment) also mentions closing the dropdown by the up arrow.
Furthermore, when opening the dropdown by space and pressing space again selects the first item. which I don't think it should.

@hnrch02 hnrch02 added the js label Oct 3, 2014
@hnrch02 hnrch02 added this to the v3.2.1 milestone Oct 3, 2014
if (!isActive || (isActive && e.keyCode == 27)) {
if (e.which == 27) $parent.find(toggle).trigger('focus')
if ((!isActive && e.keyCode != 27) || (isActive && e.keyCode == 27)) {
if (e.keyCode == 27) $parent.find(toggle).trigger('focus')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why switch to keyCode from which? I mean, keyCode should always be defined on a keydown event but which is normalized by jQuery.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i just wanted it to be consistent… seemed ghetto to check for keyCode, then check for which below

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

@fat
Copy link
Member Author

fat commented Oct 3, 2014

i disagree with closing it with up - try with the actual option input provided http://www.w3schools.com/html/tryit.asp?filename=tryhtml_select2

@fat
Copy link
Member Author

fat commented Oct 3, 2014

also, native browser space selects in that option as well, so i think space selecting when open makes sense

@hnrch02
Copy link
Collaborator

hnrch02 commented Oct 3, 2014

i disagree with closing it with up

Was just mentioning it, though the dropdowns we provide aren't really comparable to select inputs IMO.

also, native browser space selects in that option as well, so i think space selecting when open makes sense

Again not really comparable, but also it requires two space hits to select an item: The first one opens the dropdown and the second one selects the first item.

@fat
Copy link
Member Author

fat commented Oct 3, 2014

ah gotcha – i think it's fine for now. However I don't have really strong feels about it.

if you want to change it, feel free :)

going to merge this for now though

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

Successfully merging this pull request may close these issues.

Escape key should only close Dropdown
2 participants