Skip to content

Commit e8f8d07

Browse files
crisbetommalerba
authored andcommitted
fix(slide-toggle): don't show hover ripples on touch devices (#13702)
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. Related to #13675.
1 parent efe53a0 commit e8f8d07

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/lib/slide-toggle/slide-toggle.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,16 @@ $mat-slide-toggle-bar-track-width: $mat-slide-toggle-bar-width - $mat-slide-togg
214214
&, .mat-slide-toggle.mat-disabled .mat-slide-toggle-bar:hover & {
215215
opacity: 0;
216216
}
217+
218+
// Hover styles will be displayed after tapping on touch devices.
219+
// Disable the hover styling if the user's device doesn't support hovering.
220+
@media (hover: none) {
221+
// Note that we only negate the `:hover` rather than setting it to always be `display: none`,
222+
// in order to maintain the focus indication for hybrid touch + keyboard devices.
223+
.mat-slide-toggle-bar:hover & {
224+
display: none;
225+
}
226+
}
217227
}
218228

219229
/** Custom styling to make the slide-toggle usable in high contrast mode. */

0 commit comments

Comments
 (0)