-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
prevent bubbling of escape key #2713
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -237,26 +237,62 @@ class AbstractChosen | |
evt.preventDefault() | ||
this.results_show() unless @results_showing or @is_disabled | ||
|
||
keydown_checker: (evt) -> | ||
stroke = evt.which ? evt.keyCode | ||
this.search_field_scale() | ||
|
||
this.clear_backstroke() if stroke != 8 and @pending_backstroke | ||
|
||
switch stroke | ||
when 8 # backspace | ||
@backstroke_length = this.get_search_field_value().length | ||
break | ||
when 9 # tab | ||
this.result_select(evt) if @results_showing and not @is_multiple | ||
@mouse_on_container = false | ||
break | ||
when 13 # enter | ||
evt.preventDefault() if @results_showing | ||
break | ||
when 27 # escape | ||
evt.preventDefault() if @results_showing | ||
break | ||
when 32 # space | ||
evt.preventDefault() if @disable_search | ||
break | ||
when 38 # up arrow | ||
evt.preventDefault() | ||
this.keyup_arrow() | ||
break | ||
when 40 # down arrow | ||
evt.preventDefault() | ||
this.keydown_arrow() | ||
break | ||
|
||
keyup_checker: (evt) -> | ||
stroke = evt.which ? evt.keyCode | ||
this.search_field_scale() | ||
|
||
switch stroke | ||
when 8 | ||
when 8 # backspace | ||
if @is_multiple and @backstroke_length < 1 and this.choices_count() > 0 | ||
this.keydown_backstroke() | ||
else if not @pending_backstroke | ||
this.result_clear_highlight() | ||
this.results_search() | ||
when 13 | ||
break | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need to add all of these explicit Docs:
Confirmed with the "Try CoffeeScript" dingus on http://coffeescript.org/ as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know, but if you don't add them, CoffeeScript returns a value, and I wanted to get rid of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha. Fair enough. |
||
when 13 # enter | ||
evt.preventDefault() | ||
this.result_select(evt) if this.results_showing | ||
when 27 | ||
break | ||
when 27 # escape | ||
this.results_hide() if @results_showing | ||
return true | ||
when 9, 38, 40, 16, 91, 17, 18 | ||
break | ||
when 9, 16, 17, 18, 38, 40, 91 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My hero. |
||
# don't do anything on these keys | ||
else this.results_search() | ||
else | ||
this.results_search() | ||
break | ||
|
||
clipboard_event_checker: (evt) -> | ||
setTimeout (=> this.results_search()), 50 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto on all of these
break
s — can be safely removed.