From: Heinrich Fenkart Date: Tue, 1 Jul 2014 03:50:31 +0000 (+0200) Subject: Only close modal if escape was hit with keydown; fixes #13929 X-Git-Tag: v3.3.0~394^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91f329e4488c667c04ea0f3ccc8dc11aaa7124ef;p=thirdparty%2Fbootstrap.git Only close modal if escape was hit with keydown; fixes #13929 --- diff --git a/js/modal.js b/js/modal.js index 29eedf117a..92eff470ad 100644 --- a/js/modal.js +++ b/js/modal.js @@ -135,11 +135,11 @@ Modal.prototype.escape = function () { if (this.isShown && this.options.keyboard) { - this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) { + this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) { e.which == 27 && this.hide() }, this)) } else if (!this.isShown) { - this.$element.off('keyup.dismiss.bs.modal') + this.$element.off('keydown.dismiss.bs.modal') } } diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index a415129aae..5ee58616f1 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -164,6 +164,44 @@ $(function () { .bootstrapModal('show') }) + test('should close modal when escape key is pressed via keydown', function () { + stop() + + var div = $('