Skip to content

Commit 3465f92

Browse files
authored
fix(multiple): ensure mat-option parents are the offsetParent (#30977)
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 e4a1f54 commit 3465f92

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
@@ -17,8 +17,9 @@ div.mat-mdc-autocomplete-panel {
1717
padding: 8px 0;
1818
box-sizing: border-box;
1919

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

2324
@include token-utils.use-tokens($token-prefix, $token-slots) {
2425
border-radius: token-utils.slot(container-shape);

src/material/select/select.scss

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

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

170171
@include token-utils.use-tokens($token-prefix, $token-slots) {
171172
background-color: token-utils.slot(panel-background-color);
@@ -186,10 +187,6 @@ div.mat-mdc-select-panel {
186187
border-bottom-right-radius: 0;
187188
transform-origin: bottom center;
188189
}
189-
190-
.mat-mdc-option {
191-
--mat-list-list-item-container-color: var(--mat-select-panel-background-color);
192-
}
193190
}
194191

195192
.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(m2-timepicker.$prefix, m2-timepicker.get-token-slots()) {
4044
border-bottom-left-radius: token-utils.slot(container-shape);
4145
border-bottom-right-radius: token-utils.slot(container-shape);

0 commit comments

Comments
 (0)