diff options
| author | alpadev <[email protected]> | 2021-07-25 19:36:11 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-07-25 20:36:11 +0300 |
| commit | b010a6f9f4ea3dda08a4792e1367730ddcf8752d (patch) | |
| tree | 5b5c3138413244e028259b951de4d0128b4f0190 /js/tests | |
| parent | 5d24fef741944c168ad0ca9cabd1509d5803e441 (diff) | |
| download | bootstrap-b010a6f9f4ea3dda08a4792e1367730ddcf8752d.tar.xz bootstrap-b010a6f9f4ea3dda08a4792e1367730ddcf8752d.zip | |
fix(modal): change the order we return from show() method (#34087)
In case of a modal with fading enabled, a prevented show event can cause show to not showing the modal anymore.
See #34055
Co-authored-by: XhmikosR <[email protected]>
Diffstat (limited to 'js/tests')
| -rw-r--r-- | js/tests/unit/modal.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index a46b3d2de..f2c60684b 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -102,6 +102,32 @@ $(function () { .bootstrapModal('show') }) + QUnit.test('should be shown after the first call to show() has been prevented while fading is enabled', function (assert) { + assert.expect(2) + var done = assert.async() + + var $el = $('<div class="modal fade"><div class="modal-dialog" style="transition-duration: 20ms;"/></div>').appendTo('#qunit-fixture') + + var prevented = false + $el + .on('show.bs.modal', function (e) { + if (!prevented) { + e.preventDefault() + prevented = true + + setTimeout(function () { + $el.bootstrapModal('show') + }) + } + }) + .on('shown.bs.modal', function () { + assert.ok(prevented, 'show prevented') + assert.ok($el.hasClass('fade')) + done() + }) + .bootstrapModal('show') + }) + QUnit.test('should hide modal when hide is called', function (assert) { assert.expect(3) var done = assert.async() |
