diff --git a/js/bootstrap-select.js b/js/bootstrap-select.js index f26b9e58c..067a68a6e 100644 --- a/js/bootstrap-select.js +++ b/js/bootstrap-select.js @@ -2118,6 +2118,16 @@ if (doneButton) menu.appendChild(doneButton); newElement.appendChild(menu); + var newElementAnchor = $('a', $(li)); + // Get 'visible' css items to restore after calculation is done + var newElementAnchorDisplay = newElementAnchor.css('display'); + var newElementAnchorVisibility = newElementAnchor.css('visibility'); + newElementAnchor.show(); // always make sure first item is shown, otherwise offsetHeight = 0 + if (newElementAnchor.text() === '') { + // If blank, set text to non-breaking space otherwise offsetHeight = 8 (or some portion of full height) + newElementAnchor.text = ' '; + } + document.body.appendChild(newElement); var liHeight = li.offsetHeight, @@ -2170,6 +2180,9 @@ this.sizeInfo.scrollBarWidth = scrollBarWidth; this.sizeInfo.selectHeight = this.$newElement[0].offsetHeight; + if (newElementAnchorDisplay !== undefined && newElementAnchorDisplay !== '') newElementAnchor.css('display', newElementAnchorDisplay); + if (newElementAnchorVisibility !== undefined && newElementAnchorVisibility !== '') newElementAnchor.css('visibility', newElementAnchorVisibility); + this.setPositionData(); },