From 7409117176d458f8df47f2ce69e495aa8d595e83 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 11 Jun 2015 17:16:06 +0200 Subject: [PATCH] close modal form by pressing escape even if input is focused --- .../sonar-web/src/main/js/components/common/modal-form.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/sonar-web/src/main/js/components/common/modal-form.js b/server/sonar-web/src/main/js/components/common/modal-form.js index 8fca522d40d..736621c9bed 100644 --- a/server/sonar-web/src/main/js/components/common/modal-form.js +++ b/server/sonar-web/src/main/js/components/common/modal-form.js @@ -29,6 +29,7 @@ define(['components/common/modals'], function (ModalView) { events: function () { return _.extend(ModalView.prototype.events.apply(this, arguments), { + 'keydown input,textarea,select': 'onInputKeydown', 'submit form': 'onFormSubmit' }); }, @@ -41,6 +42,13 @@ define(['components/common/modals'], function (ModalView) { }, 0); }, + onInputKeydown: function (e) { + if (e.keyCode === 27) { + // escape + this.destroy(); + } + }, + onFormSubmit: function (e) { e.preventDefault(); }, -- 2.39.5