Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit d8d3e4c

Browse files
committed
fix(select): fix positioning when using option groups
references #3594
1 parent 898fd9b commit d8d3e4c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/components/select/select.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,20 +1018,23 @@ function SelectProvider($$interimElementProvider) {
10181018
selectNode.classList.add('md-overflow');
10191019
}
10201020

1021+
var focusedNode = centeredNode;
1022+
if ((focusedNode.tagName || '').toUpperCase() === 'MD-OPTGROUP') {
1023+
focusedNode = optionNodes[0] || contentNode.firstElementChild || contentNode;
1024+
centeredNode = focusedNode;
1025+
}
1026+
10211027
// Get the selectMenuRect *after* max-width is possibly set above
10221028
var selectMenuRect = selectNode.getBoundingClientRect();
10231029
var centeredRect = getOffsetRect(centeredNode);
10241030

1031+
10251032
if (centeredNode) {
10261033
var centeredStyle = $window.getComputedStyle(centeredNode);
10271034
centeredRect.paddingLeft = parseInt(centeredStyle.paddingLeft, 10) || 0;
10281035
centeredRect.paddingRight = parseInt(centeredStyle.paddingRight, 10) || 0;
10291036
}
10301037

1031-
var focusedNode = centeredNode;
1032-
if ((focusedNode.tagName || '').toUpperCase() === 'MD-OPTGROUP') {
1033-
focusedNode = optionNodes[0] || contentNode.firstElementChild || contentNode;
1034-
}
10351038

10361039
if (isScrollable) {
10371040
var scrollBuffer = contentNode.offsetHeight / 2;

0 commit comments

Comments
 (0)