Skip to content

Commit ac4ce8b

Browse files
committed
Merge pull request select2#635 from t0m/multi-select-dropdown
Fix for more than one multi-select being open at the same time
2 parents c135db8 + b33c86e commit ac4ce8b

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

select2.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -509,17 +509,20 @@ the specific language governing permissions and limitations under the Apache Lic
509509
$document.ready(function () {
510510
$document.bind("mousedown touchend", function (e) {
511511
var target = $(e.target).closest("div.select2-container").get(0), attr;
512+
var targetDropdown = null;
512513
if (target) {
513514
$document.find("div.select2-container-active").each(function () {
514515
if (this !== target) $(this).data("select2").blur();
515516
});
516-
} else {
517-
target = $(e.target).closest("div.select2-drop").get(0);
518-
$document.find("div.select2-drop-active").each(function () {
519-
if (this !== target) $(this).data("select2").blur();
520-
});
517+
targetDropdown = $(target).data('select2').dropdown.get(0);
521518
}
522519

520+
// close any other active dropdowns
521+
target = targetDropdown || $(e.target).closest("div.select2-drop").get(0);
522+
$document.find("div.select2-drop-active").each(function () {
523+
if (this !== target) $(this).data("select2").blur();
524+
});
525+
523526
target=$(e.target);
524527
attr = target.attr("for");
525528
if ("LABEL" === e.target.tagName && attr && attr.length > 0) {

0 commit comments

Comments
 (0)