Skip to content

Commit 4f52c4f

Browse files
committed
fix(checkbox): don't show hover ripples on touch devices
On touch devices `:hover` styling persists after the user has tapped. These changes hide the persistent ripple if the user isn't able to hover, in order to avoid confusion with the other ripples. Fixes #13675.
1 parent efeefd1 commit 4f52c4f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/lib/checkbox/checkbox.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,16 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * $mat-checkbox-size !default;
276276
&, .mat-checkbox.mat-disabled .mat-checkbox-inner-container:hover & {
277277
opacity: 0;
278278
}
279+
280+
// Hover styles will be displayed after tapping on touch devices.
281+
// Disable the hover styling if the user's device doesn't support hovering.
282+
@media (hover: none) {
283+
// Note that we only negate the `:hover` rather than setting it to always be `display: none`,
284+
// in order to maintain the focus indication for hybrid touch + keyboard devices.
285+
.mat-checkbox-inner-container:hover & {
286+
display: none;
287+
}
288+
}
279289
}
280290

281291
.mat-checkbox-checkmark {

0 commit comments

Comments
 (0)