Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

fix(dropdown): stop esc keydown event #5787

Closed
wants to merge 1 commit into from

Conversation

deeg
Copy link
Contributor

@deeg deeg commented Apr 12, 2016

Fixes #5778

BREAKING CHANGE: Stops propagation of keydown event when escape key is pressed. Removes keydown event from the document and moves it to the dropdown element.

Plunker with fix

deeg added a commit to deeg/bootstrap that referenced this pull request Apr 12, 2016
Fixes angular-ui#5778
Closes angular-ui#5787

BREAKING CHANGE: Stops propagation of keydown event when escape key is pressed. Removes keydown event from the document and moves it to the dropdown element.
@deeg
Copy link
Contributor Author

deeg commented Apr 12, 2016

@wesleycho, not sure if switching the keydown event from document to element will have any ramifications I didn't think about. Escape and keyboard nav still seems to work fine for me in the linked plunker.

The reason I did this was because the document event was catching after the modal escape key event had already fired so stopPropagation didn't do anything. Couldn't think of a nicer way to solve this than to move the event over to the element.

@@ -26,8 +26,10 @@ describe('uib-dropdown', function() {

var triggerKeyDown = function (element, keyCode) {
var e = $.Event('keydown');
spyOn(e, "stopPropagation");
Copy link
Contributor

Choose a reason for hiding this comment

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

Use single quotes - also add .and.callThrough()

@wesleycho
Copy link
Contributor

I think that switch is ok, judging by the code and playing around with the Plunker.

I'm ok with this change.

@wesleycho wesleycho added this to the 1.3.2 milestone Apr 12, 2016
Fixes angular-ui#5778
Closes angular-ui#5787

BREAKING CHANGE: Stops propagation of keydown event when escape key is pressed. Removes keydown event from the document and moves it to the dropdown element.
@deeg
Copy link
Contributor Author

deeg commented Apr 12, 2016

@wesleycho, sounds good, thanks.

I made the requested changes.

@wesleycho
Copy link
Contributor

LGTM if it passes the tests

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

Successfully merging this pull request may close these issues.

Pressing ESC with a dropdown inside a modal dialog
2 participants