Skip to content

Commit

Permalink
Merge pull request #24240 from lucascono/v4-dev
Browse files Browse the repository at this point in the history
Fix modal when we try to show that modal two times
  • Loading branch information
Johann-S authored Oct 4, 2017
2 parents 1c24bde + be9e6f3 commit 133cc32
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js/src/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const Modal = (() => {
}

show(relatedTarget) {
if (this._isTransitioning) {
if (this._isTransitioning || this._isShown) {
return
}

Expand Down
16 changes: 16 additions & 0 deletions js/tests/unit/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -673,4 +673,20 @@ $(function () {
$toggleBtn.trigger('click')
setTimeout(done, 500)
})

QUnit.test('should not try to open a modal which is already visible', function (assert) {
assert.expect(1)
var done = assert.async()
var count = 0

$('<div id="modal-test"/>').on('shown.bs.modal', function () {
count++
}).on('hidden.bs.modal', function () {
assert.strictEqual(count, 1, 'show() runs only once')
done()
})
.bootstrapModal('show')
.bootstrapModal('show')
.bootstrapModal('hide')
})
})

0 comments on commit 133cc32

Please sign in to comment.