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

ESC does not propagate even after closing suggestions #57

Closed
ThiefMaster opened this Issue Jul 22, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@ThiefMaster

ThiefMaster commented Jul 22, 2015

Initially an ESC keypress in the text field propagates up the dom tree. When suggestions are displayed, it closes the suggestions instead. Another ESC keypress afterwards doesn't propagate up anymore.

I think ESC should propagate normally while no suggestions are shown. For example, we're showing a form in a dialog that can be closed with ESC, but that doesn't work while focusing the typeahead-enhanced field once suggestions had been shown.

@running-coder

This comment has been minimized.

Owner

running-coder commented Jul 22, 2015

Hey ThiefMaster,

Good call!

I'm not using .stopPropagation but .preventDefault for the ESC case,
https://github.com/running-coder/jquery-typeahead/blob/master/src/jquery.typeahead.js#L859

I'll look into .stopImmediatePropagation() my goal is to close the Typeahead result list but indeed I'm blocking any further actions

@running-coder running-coder added the Bug label Jul 22, 2015

@ThiefMaster

This comment has been minimized.

ThiefMaster commented Jul 22, 2015

Ah.. Apparently the jQuery UI dialog ignores ESC if the default action is prevented:

            keydown: function( event ) {
                if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
                        event.keyCode === $.ui.keyCode.ESCAPE ) {
@ThiefMaster

This comment has been minimized.

ThiefMaster commented Jul 22, 2015

I think the only problem is that the event is preventDefaulted even if the result list wasn't open (if it is open, then preventDefault/stopPropagation makes lots of sense)

@running-coder running-coder added this to the 2.1.2 milestone Sep 28, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment