Skip to content

Commit 33a7217

Browse files
authored
fix(multiple): ensure mat-option parents are the offsetParent (#30977) (#30980)
We have several components where we use the `offsetTop` of the `mat-option` to determine how much to scroll, however this only works if the panel is the option's `offsetParent`. For that to happen we need a position different from `static`. Fixes #30974.
1 parent 63c5e00 commit 33a7217

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/material/autocomplete/autocomplete.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ div.mat-mdc-autocomplete-panel {
1414
padding: 8px 0;
1515
box-sizing: border-box;
1616

17-
// Workaround in case other MDC menu surface styles bleed in.
18-
position: static;
17+
// Necessary so the `offsetParent` of the nested `mat-option` is the
18+
// panel which is required for scroll calculations (see #30974).
19+
position: relative;
1920

2021
@include token-utils.use-tokens(
2122
tokens-mat-autocomplete.$prefix, tokens-mat-autocomplete.get-token-slots()) {

src/material/select/select.scss

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@ div.mat-mdc-select-panel {
165165
border-radius: 4px;
166166
box-sizing: border-box;
167167

168-
// Workaround in case other MDC menu surface styles bleed in.
169-
position: static;
168+
// Necessary so the `offsetParent` of the nested `mat-option` is the
169+
// panel which is required for scroll calculations (see #30974).
170+
position: relative;
170171

171172
@include token-utils.use-tokens(
172173
tokens-mat-select.$prefix, tokens-mat-select.get-token-slots()) {
@@ -188,10 +189,6 @@ div.mat-mdc-select-panel {
188189
border-bottom-right-radius: 0;
189190
transform-origin: bottom center;
190191
}
191-
192-
.mat-mdc-option {
193-
--mdc-list-list-item-container-color: var(--mat-select-panel-background-color);
194-
}
195192
}
196193

197194
.mat-select-panel-animations-enabled {

src/material/timepicker/timepicker.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ mat-timepicker {
3636
padding: 8px 0;
3737
box-sizing: border-box;
3838

39+
// Necessary so the `offsetParent` of the nested `mat-option` is the
40+
// panel which is required for scroll calculations (see #30974).
41+
position: relative;
42+
3943
@include token-utils.use-tokens(
4044
tokens-mat-timepicker.$prefix, tokens-mat-timepicker.get-token-slots()) {
4145
@include token-utils.create-token-slot(border-bottom-left-radius, container-shape);

0 commit comments

Comments
 (0)