Skip to content

Commit 795c956

Browse files
crisbetojosephperrott
authored andcommitted
fix(list): disable hover styling on touch devices (#12520)
1 parent 7dff5f8 commit 795c956

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/lib/list/list.scss

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ $mat-list-item-inset-divider-offset: 72px;
209209
.mat-list, .mat-nav-list, .mat-selection-list {
210210
padding-top: $mat-list-top-padding;
211211
display: block;
212+
-webkit-tap-highlight-color: transparent;
212213

213214
.mat-subheader {
214215
@include mat-subheader-spacing($mat-list-top-padding, $mat-list-base-height);
@@ -228,8 +229,9 @@ $mat-list-item-inset-divider-offset: 72px;
228229
}
229230

230231

231-
.mat-list[dense], .mat-nav-list[dense], .mat-selection-list[dense] {
232-
232+
.mat-list[dense],
233+
.mat-nav-list[dense],
234+
.mat-selection-list[dense] {
233235
padding-top: $mat-dense-top-padding;
234236
display: block;
235237

@@ -266,3 +268,16 @@ $mat-list-item-inset-divider-offset: 72px;
266268
cursor: pointer;
267269
outline: none;
268270
}
271+
272+
273+
// Disable the hover styles on non-hover devices. Since this is more of a progressive
274+
// enhancement and not all desktop browsers support this kind of media query, we can't
275+
// use something like `@media (hover)`.
276+
@media (hover: none) {
277+
.mat-list-option,
278+
.mat-nav-list .mat-list-item {
279+
&:hover {
280+
background: none;
281+
}
282+
}
283+
}

0 commit comments

Comments
 (0)