Skip to content

Commit 2342d91

Browse files
committed
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.
1 parent 2d906ee commit 2342d91

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

select2.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,8 @@ the specific language governing permissions and limitations under the Apache Lic
773773
// trap all mouse events from leaving the dropdown. sometimes there may be a modal that is listening
774774
// for mouse events outside of itself so it can close itself. since the dropdown is now outside the select2's
775775
// dom it will trigger the popup close, which is not what we want
776-
this.dropdown.on("click mouseup mousedown", function (e) { e.stopPropagation(); });
776+
// focusin can cause focus wars between modals and select2 since the dropdown is outside the modal.
777+
this.dropdown.on("click mouseup mousedown focusin", function (e) { e.stopPropagation(); });
777778

778779
this.nextSearchTerm = undefined;
779780

0 commit comments

Comments
 (0)