diff options
| author | Heinrich Fenkart <[email protected]> | 2014-07-01 05:50:31 +0200 |
|---|---|---|
| committer | Heinrich Fenkart <[email protected]> | 2014-07-01 05:50:31 +0200 |
| commit | 91f329e4488c667c04ea0f3ccc8dc11aaa7124ef (patch) | |
| tree | 5ecf1ba79ad1d6137bfbe4075df3a692df8515a8 /js/tests | |
| parent | 8deab3a95d24afa795c428572b7bfadbc7fb9ac5 (diff) | |
| download | bootstrap-91f329e4488c667c04ea0f3ccc8dc11aaa7124ef.tar.xz bootstrap-91f329e4488c667c04ea0f3ccc8dc11aaa7124ef.zip | |
Only close modal if escape was hit with keydown; fixes #13929
Diffstat (limited to 'js/tests')
| -rw-r--r-- | js/tests/unit/modal.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index a415129aa..5ee58616f 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 = $('<div id="modal-test"/>') + div + .on('shown.bs.modal', function () { + ok($('#modal-test').length, 'modal insterted into dom') + ok($('#modal-test').is(':visible'), 'modal visible') + div.trigger($.Event('keydown', { which: 27 })) + + setTimeout(function () { + ok(!$('#modal-test').is(':visible'), 'modal hidden') + div.remove() + start() + }, 0) + }) + .bootstrapModal('show') + }) + + test('should not close modal when escape key is pressed via keyup', function () { + stop() + + var div = $('<div id="modal-test"/>') + div + .on('shown.bs.modal', function () { + ok($('#modal-test').length, 'modal insterted into dom') + ok($('#modal-test').is(':visible'), 'modal visible') + div.trigger($.Event('keyup', { which: 27 })) + + setTimeout(function () { + ok($('#modal-test').is(':visible'), 'modal still visible') + div.remove() + start() + }, 0) + }) + .bootstrapModal('show') + }) + test('should trigger hide event once when clicking outside of modal-content', function () { stop() $.support.transition = false |
