Skip to content

Commit

Permalink
Fixed scrolling bug when closeOnSelect is false
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanheywood committed Oct 31, 2012
1 parent 4a363c4 commit 291f595
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ the specific language governing permissions and limitations under the Apache Lic
y = child.offset().top - results.offset().top;

// make sure the top of the element is visible
if (y < 0) {
if (y < 0 && child.css('display') != 'none' ) {
results.scrollTop(results.scrollTop() + y); // y is negative
}
},
Expand Down Expand Up @@ -2166,12 +2166,14 @@ the specific language governing permissions and limitations under the Apache Lic
}
});

choices.each2(function (i, choice) {
if (!choice.hasClass("select2-disabled") && choice.hasClass("select2-result-selectable")) {
self.highlight(0);
return false;
}
});
if (this.opts.closeOnSelect){
choices.each2(function (i, choice) {
if (!choice.hasClass("select2-disabled") && choice.hasClass("select2-result-selectable")) {
self.highlight(0);
return false;
}
});
}

},

Expand Down

0 comments on commit 291f595

Please sign in to comment.