diff --git a/js/modal.js b/js/modal.js index 5049cccf36..cba48507a4 100644 --- a/js/modal.js +++ b/js/modal.js @@ -140,7 +140,9 @@ $(document) .off('focusin.bs.modal') // guard against infinite focus loop .on('focusin.bs.modal', $.proxy(function (e) { - if (this.$element[0] !== e.target && !this.$element.has(e.target).length) { + if (document !== event.target && + this.$element[0] !== e.target && + !this.$element.has(e.target).length) { this.$element.trigger('focus') } }, this)) diff --git a/js/tests/visual/modal.html b/js/tests/visual/modal.html index 4342f0ce44..865511f97c 100644 --- a/js/tests/visual/modal.html +++ b/js/tests/visual/modal.html @@ -127,12 +127,37 @@ +