Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(dialog): correctly disable keydown listener for escapeToClose
Browse files Browse the repository at this point in the history
Currently there was a duplicated variable `target`, which got replaced later and the `target` variable became the actual `element` not the `parent` anymore.

Fixes #7214 Fixes #5153

  Closes #7222
  • Loading branch information
devversion authored and ThomasBurleson committed Feb 26, 2016
1 parent b944ea1 commit 35de3d1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ function MdDialogProvider($$interimElementProvider) {
};

if (options.escapeToClose) {
var target = options.parent;
var parentTarget = options.parent;
var keyHandlerFn = function(ev) {
if (ev.keyCode === $mdConstant.KEY_CODE.ESCAPE) {
ev.stopPropagation();
Expand All @@ -744,13 +744,13 @@ function MdDialogProvider($$interimElementProvider) {

// Add keydown listeners
element.on('keydown', keyHandlerFn);
target.on('keydown', keyHandlerFn);
parentTarget.on('keydown', keyHandlerFn);

// Queue remove listeners function
removeListeners.push(function() {

element.off('keydown', keyHandlerFn);
target.off('keydown', keyHandlerFn);
parentTarget.off('keydown', keyHandlerFn);

});
}
Expand Down

0 comments on commit 35de3d1

Please sign in to comment.