Skip to content

Commit b33c86e

Browse files
committed
Fixes >1 multi-select dropdown being open at the same time
Bug was reproduced on latest FF/Chrome/Safari, but IE exibits correct behavior with or without the fix. See: http://jsfiddle.net/tmD7c/2/
1 parent c135db8 commit b33c86e

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)