Skip to content

Commit

Permalink
fix(button): persist theme color of button when leaving hover state (#…
Browse files Browse the repository at this point in the history
…3629)

For all buttons that need the focus overlay to be visible on on focus, that is already covered in `_button-base.scss`.

For flat or icon buttons that need the focus overlay to be visible on hover, that is already covered in `button.scss`.

All disabled buttons should always hide the focus overlay.
  • Loading branch information
willshowell authored and mmalerba committed Mar 17, 2017
1 parent b810e11 commit 3ad6ff0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
17 changes: 8 additions & 9 deletions src/lib/button/_button-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
&.mat-warn .mat-button-focus-overlay {
background-color: mat-color($warn, 0.12);
}

&[disabled] .mat-button-focus-overlay {
background-color: transparent;
}
}

// Applies a property to an md-button element for each of the supported palettes.
Expand Down Expand Up @@ -54,20 +58,15 @@
$foreground: map-get($theme, foreground);

.mat-button, .mat-icon-button, .mat-raised-button, .mat-fab, .mat-mini-fab {
&.cdk-keyboard-focused {
@include _mat-button-focus-color($theme);
}
// Appy color to focus overlay.
// The focus overlay will be visible when any button type is focused or when
// flat buttons or icon buttons are hovered.
@include _mat-button-focus-color($theme);
}

.mat-button, .mat-icon-button {
@include _mat-button-theme-color($theme, 'color');
background: transparent;

// Only flat buttons and icon buttons (not raised or fabs) have a hover style.
// Use the same visual treatment for hover as for focus.
&:hover {
@include _mat-button-focus-color($theme);
}
}

.mat-raised-button, .mat-fab, .mat-mini-fab {
Expand Down
6 changes: 0 additions & 6 deletions src/lib/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@
opacity: 1;
}
}

&[disabled]:hover {
&.mat-primary, &.mat-accent, &.mat-warn, .mat-button-focus-overlay {
background-color: transparent;
}
}
}

.mat-raised-button {
Expand Down

0 comments on commit 3ad6ff0

Please sign in to comment.