From 291f595a03ef39495dda6e837d8f002464d2470b Mon Sep 17 00:00:00 2001 From: Brendan Heywood Date: Wed, 31 Oct 2012 16:35:34 +1000 Subject: [PATCH] Fixed scrolling bug when closeOnSelect is false --- select2.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/select2.js b/select2.js index d3e1b349..0cc6aeaa 100644 --- a/select2.js +++ b/select2.js @@ -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 } }, @@ -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; + } + }); + } },