Skip to content

fix(button-toggle): remove hover state on touch devices #13724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/lib/button-toggle/button-toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ $mat-button-toggle-legacy-border-radius: 2px !default;
white-space: nowrap;
overflow: hidden;
border-radius: $mat-button-toggle-legacy-border-radius;
-webkit-tap-highlight-color: transparent;

@include cdk-high-contrast {
outline: solid 1px;
Expand Down Expand Up @@ -47,7 +48,6 @@ $mat-button-toggle-legacy-border-radius: 2px !default;
.mat-button-toggle {
white-space: nowrap;
position: relative;
-webkit-tap-highlight-color: transparent;

&.cdk-keyboard-focused {
.mat-button-toggle-focus-overlay {
Expand Down Expand Up @@ -78,6 +78,16 @@ $mat-button-toggle-legacy-border-radius: 2px !default;
opacity: 0.5;
}
}

// On touch devices the hover state will linger on the element after the user has tapped.
// Disable it, because it can be confused with focus. We target the :hover state explicitly,
// because we still want to preserve the keyboard focus state for hybrid devices that have
// a keyboard and a touchscreen.
@media (hover: none) {
&:not(.mat-button-toggle-disabled):hover .mat-button-toggle-focus-overlay {
display: none;
}
}
}

.mat-button-toggle-label-content {
Expand Down