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

Commit 72f8dfd

Browse files
devversionThomasBurleson
authored andcommitted
fix(dialog): correctly disable keydown listener for escapeToClose
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
1 parent 6e685c3 commit 72f8dfd

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/components/dialog/dialog.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ function MdDialogProvider($$interimElementProvider) {
775775
};
776776

777777
if (options.escapeToClose) {
778-
var target = options.parent;
778+
var parentTarget = options.parent;
779779
var keyHandlerFn = function(ev) {
780780
if (ev.keyCode === $mdConstant.KEY_CODE.ESCAPE) {
781781
ev.stopPropagation();
@@ -787,13 +787,13 @@ function MdDialogProvider($$interimElementProvider) {
787787

788788
// Add keydown listeners
789789
element.on('keydown', keyHandlerFn);
790-
target.on('keydown', keyHandlerFn);
790+
parentTarget.on('keydown', keyHandlerFn);
791791

792792
// Queue remove listeners function
793793
removeListeners.push(function() {
794794

795795
element.off('keydown', keyHandlerFn);
796-
target.off('keydown', keyHandlerFn);
796+
parentTarget.off('keydown', keyHandlerFn);
797797

798798
});
799799
}

0 commit comments

Comments
 (0)