Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

max-height/offsetHeight Calculation Issue, Fixes #2581 #2700

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions js/bootstrap-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
},

Expand Down