Skip to content

Commit 124ea5a

Browse files
authored
fix(datepicker): disable calendar hover styles on touch devices (#18876)
Browsers on touch devices show the hover styles on tap which can be confusing for users, because it's the same as the focus styles. These changes disable the hover styles on browsers that don't support hovering.
1 parent 1718d78 commit 124ea5a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/material/datepicker/calendar-body.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,14 @@ $mat-calendar-body-cell-content-size: 100% - $mat-calendar-body-cell-content-mar
9090
text-align: right;
9191
}
9292
}
93+
94+
// Disable the hover styles on non-hover devices. Since this is more of a progressive
95+
// enhancement and not all desktop browsers support this kind of media query, we can't
96+
// use something like `@media (hover)`.
97+
@media (hover: none) {
98+
.mat-calendar-body-cell:not(.mat-calendar-body-disabled):hover {
99+
& > .mat-calendar-body-cell-content:not(.mat-calendar-body-selected) {
100+
background-color: transparent;
101+
}
102+
}
103+
}

0 commit comments

Comments
 (0)