fixed above/below dropdown opening bug
This commit is contained in:
parent
3a830a2b81
commit
39aa17a790
13
select2.js
13
select2.js
@ -736,11 +736,14 @@
|
|||||||
viewportBottom = $(window).scrollTop() + document.documentElement.clientHeight,
|
viewportBottom = $(window).scrollTop() + document.documentElement.clientHeight,
|
||||||
dropTop = offset.top + height,
|
dropTop = offset.top + height,
|
||||||
enoughRoomBelow = dropTop + dropHeight <= viewportBottom,
|
enoughRoomBelow = dropTop + dropHeight <= viewportBottom,
|
||||||
enoughRoomAbove = (offset.top - dropHeight) >= this.body().scrollTop,
|
enoughRoomAbove = (offset.top - dropHeight) >= this.body().scrollTop(),
|
||||||
aboveNow = this.dropdown.hasClass("select2-drop-above"),
|
aboveNow = this.dropdown.hasClass("select2-drop-above"),
|
||||||
above,
|
above,
|
||||||
css;
|
css;
|
||||||
|
|
||||||
|
//console.log("droptop:", dropTop, "dropHeight", dropHeight, "sum", (dropTop+dropHeight)+" viewport bottom", viewportBottom, "enough?", enoughRoomBelow);
|
||||||
|
//console.log("offset.top", offset.top, "dropHeight", dropHeight, "top", (offset.top-dropHeight), "scrollTop", this.body().scrollTop(), "enough?", enoughRoomAbove);
|
||||||
|
|
||||||
// always prefer the current above/below alignment, unless there is not enough room
|
// always prefer the current above/below alignment, unless there is not enough room
|
||||||
|
|
||||||
if (aboveNow) {
|
if (aboveNow) {
|
||||||
@ -814,8 +817,7 @@
|
|||||||
if (this.search.val() === " ") { this.search.val(""); }
|
if (this.search.val() === " ") { this.search.val(""); }
|
||||||
|
|
||||||
this.dropdown.addClass("select2-drop-active");
|
this.dropdown.addClass("select2-drop-active");
|
||||||
|
this.container.addClass("select2-dropdown-open").addClass("select2-container-active");
|
||||||
this.positionDropdown();
|
|
||||||
|
|
||||||
this.updateResults(true);
|
this.updateResults(true);
|
||||||
|
|
||||||
@ -826,7 +828,7 @@
|
|||||||
this.dropdown.show();
|
this.dropdown.show();
|
||||||
this.ensureHighlightVisible();
|
this.ensureHighlightVisible();
|
||||||
this.focusSearch();
|
this.focusSearch();
|
||||||
this.container.addClass("select2-dropdown-open").addClass("select2-container-active");
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// abstract
|
// abstract
|
||||||
@ -1003,6 +1005,9 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// position dropdown before making a potentially long request
|
||||||
|
this.positionDropdown();
|
||||||
|
|
||||||
this.resultsPage = 1;
|
this.resultsPage = 1;
|
||||||
opts.query({
|
opts.query({
|
||||||
term: search.val(),
|
term: search.val(),
|
||||||
|
Loading…
Reference in New Issue
Block a user