Merge pull request #2444 from surgeforward/undefined-top
Fix error: Cannot read property 'top' of undefined
This commit is contained in:
commit
5a7d250071
@ -1483,7 +1483,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
|
|
||||||
// abstract
|
// abstract
|
||||||
ensureHighlightVisible: function () {
|
ensureHighlightVisible: function () {
|
||||||
var results = this.results, children, index, child, hb, rb, y, more;
|
var results = this.results, children, index, child, hb, rb, y, more, topOffset;
|
||||||
|
|
||||||
index = this.highlight();
|
index = this.highlight();
|
||||||
|
|
||||||
@ -1503,7 +1503,9 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
|
|
||||||
child = $(children[index]);
|
child = $(children[index]);
|
||||||
|
|
||||||
hb = child.offset().top + child.outerHeight(true);
|
topOffset = (child.offset() || {}).top || 0;
|
||||||
|
|
||||||
|
hb = topOffset + child.outerHeight(true);
|
||||||
|
|
||||||
// if this is the last child lets also make sure select2-more-results is visible
|
// if this is the last child lets also make sure select2-more-results is visible
|
||||||
if (index === children.length - 1) {
|
if (index === children.length - 1) {
|
||||||
@ -1517,7 +1519,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
if (hb > rb) {
|
if (hb > rb) {
|
||||||
results.scrollTop(results.scrollTop() + (hb - rb));
|
results.scrollTop(results.scrollTop() + (hb - rb));
|
||||||
}
|
}
|
||||||
y = child.offset().top - results.offset().top;
|
y = topOffset - results.offset().top;
|
||||||
|
|
||||||
// make sure the top of the element is visible
|
// make sure the top of the element is visible
|
||||||
if (y < 0 && child.css('display') != 'none' ) {
|
if (y < 0 && child.css('display') != 'none' ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user