Skip to content

Commit

Permalink
elastic#10099 change from .bind to .on and remove unnecessary onKeyDo…
Browse files Browse the repository at this point in the history
…wn call
  • Loading branch information
dpenny52 committed Feb 28, 2017
1 parent e1b31c6 commit 6761493
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
13 changes: 3 additions & 10 deletions src/ui/public/modals/__tests__/confirm_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,7 @@ describe('ui/modals/confirm_modal', function () {
confirmButtonText: 'bye',
onConfirm: confirmCallback,
onCancel: cancelCallback,
onClose: closeCallback,
title: 'hi',
showClose: false
title: 'hi'
};

confirmModal('hi', confirmModalOptions);
Expand All @@ -203,18 +201,13 @@ describe('ui/modals/confirm_modal', function () {
confirmButtonText: 'bye',
onConfirm: confirmCallback,
onCancel: cancelCallback,
onClose: closeCallback,
title: 'hi',
showClose: false
title: 'hi'
};

confirmModal('hi', confirmModalOptions);

const e = angular.element.Event('keydown'); // eslint-disable-line new-cap
e.keyCode = 27;
while(e.keyCode === 27) {
e.keyCode = Math.floor((Math.random() * 100) + 1);
}
e.keyCode = 50;
angular.element(document.body).trigger(e);

expect(cancelCallback.called).to.be(false);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/modals/modal_overlay.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<div class="kuiModalOverlay" ng-keydown="onKeyDown($event)"></div>
<div class="kuiModalOverlay"></div>
6 changes: 2 additions & 4 deletions src/ui/public/modals/modal_overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ export class ModalOverlay {
this.overlayElement = angular.element(modalOverlayTemplate);
this.overlayElement.append(modalElement);

const onKeyDown = (event) => {
angular.element(document.body).on('keydown', (event) => {
if(event.keyCode === 27) {
scope.onCancel();
}
};

angular.element(document.body).bind('keydown', onKeyDown);
});
angular.element(document.body).append(this.overlayElement);
}

Expand Down

0 comments on commit 6761493

Please sign in to comment.