From 2342d919256f2ff3dc195f3ea73747947c8368a2 Mon Sep 17 00:00:00 2001 From: Matt Slocum Date: Tue, 11 Mar 2014 12:14:17 -0600 Subject: [PATCH] Fix Focus war with modals Bootstrap modal (and maybe others) require focus to maintain in the modal (because that what a modal is). The dropdown is outside of the modal, so we need to stopPropagation on the event so the modal doesn't know. --- select2.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/select2.js b/select2.js index f2496485..eabc25ee 100644 --- a/select2.js +++ b/select2.js @@ -773,7 +773,8 @@ the specific language governing permissions and limitations under the Apache Lic // trap all mouse events from leaving the dropdown. sometimes there may be a modal that is listening // for mouse events outside of itself so it can close itself. since the dropdown is now outside the select2's // dom it will trigger the popup close, which is not what we want - this.dropdown.on("click mouseup mousedown", function (e) { e.stopPropagation(); }); + // focusin can cause focus wars between modals and select2 since the dropdown is outside the modal. + this.dropdown.on("click mouseup mousedown focusin", function (e) { e.stopPropagation(); }); this.nextSearchTerm = undefined;