aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann-S <[email protected]>2017-10-04 14:15:05 +0200
committerGitHub <[email protected]>2017-10-04 14:15:05 +0200
commit133cc321977ce97d5a688bf32aa2917408e48a6c (patch)
tree4455010cdddbb1a20787e31cfcf0ae5036507d9b
parent1c24bdeca89e419da5ad2fc819e43fb96a912019 (diff)
parentbe9e6f3638b00c0c79c6fb06a83f6b07edb865c0 (diff)
downloadbootstrap-133cc321977ce97d5a688bf32aa2917408e48a6c.tar.xz
bootstrap-133cc321977ce97d5a688bf32aa2917408e48a6c.zip
Merge pull request #24240 from lucascono/v4-dev
Fix modal when we try to show that modal two times
-rw-r--r--js/src/modal.js2
-rw-r--r--js/tests/unit/modal.js16
2 files changed, 17 insertions, 1 deletions
diff --git a/js/src/modal.js b/js/src/modal.js
index fb787208d..1ea630c41 100644
--- a/js/src/modal.js
+++ b/js/src/modal.js
@@ -113,7 +113,7 @@ const Modal = (() => {
}
show(relatedTarget) {
- if (this._isTransitioning) {
+ if (this._isTransitioning || this._isShown) {
return
}
diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js
index e026cd7f1..e081a6dc2 100644
--- a/js/tests/unit/modal.js
+++ b/js/tests/unit/modal.js
@@ -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')
+ })
})