Skip to content

Commit

Permalink
use liData.position to scroll to selected option (takes optgroup head…
Browse files Browse the repository at this point in the history
…ers and dividers into account) (#2251)
  • Loading branch information
caseyjhol committed Apr 2, 2019
1 parent 3093246 commit 7330c23
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions js/bootstrap-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -1961,8 +1961,10 @@
selectedIndex = (element.options[element.selectedIndex] || {}).liIndex;

if (typeof selectedIndex === 'number' && that.options.size !== false) {
offset = that.sizeInfo.liHeight * selectedIndex;
offset = offset - (that.sizeInfo.menuInnerHeight / 2) + (that.sizeInfo.liHeight / 2);
var selectedData = that.selectpicker.main.data[selectedIndex],
position = selectedData && selectedData.position;

offset = position ? position - ((that.sizeInfo.menuInnerHeight + that.sizeInfo.liHeight) / 2) : 0;
}
}

Expand Down

0 comments on commit 7330c23

Please sign in to comment.