Skip to content

Commit 48c20c7

Browse files
issue #4737 - Enter/Esc listener bound to window instead of popup element
1 parent bdf7a3a commit 48c20c7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

js/angular/service/popup.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ function($ionicTemplateLoader, $ionicBackdrop, $q, $timeout, $rootScope, $ionicB
396396
// popup.keyPressHandlers is a list of event-listener handles returned by addEventListener()
397397
// and is used to unbind these event listeners when the popup is closing ("then" block below)
398398
popup.element[0].keyPressHandlers = options.keyPressHandlers || {};
399-
popup.keylistener = popup.element[0].addEventListener('keypress', function (keyEvent) {
400-
var userfunc = this.keyPressHandlers[keyEvent.keyCode];
399+
popup.keylistener = window.addEventListener('keypress', function (keyEvent) {
400+
var userfunc = popup.element[0].keyPressHandlers[keyEvent.keyCode];
401401
if (userfunc) userfunc(popup);
402402
});
403403

@@ -415,7 +415,7 @@ function($ionicTemplateLoader, $ionicBackdrop, $q, $timeout, $rootScope, $ionicB
415415
popupStack.splice(index, 1);
416416
}
417417

418-
popup.element[0].removeEventListener('keypress', popup.keylistener);
418+
window.removeEventListener('keypress', popup.keylistener);
419419

420420
popup.remove();
421421

0 commit comments

Comments
 (0)