Skip to content

Commit d744a5f

Browse files
tinayuangaommalerba
authored andcommitted
fix(button-toggle): only show focus style when focused via keyboard (#3232)
* Use a lighter color for focused layer in button-toggle * . * Only show focus layer when keyboard focus
1 parent a306a8e commit d744a5f

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/lib/button-toggle/_button-toggle-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
$background: map-get($theme, background);
77

88
.mat-button-toggle-focus-overlay {
9-
background-color: mat-color($background, dark-overlay);
9+
background-color: mat-color($background, focused-button);
1010
}
1111
}
1212

src/lib/button-toggle/button-toggle.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ $mat-button-toggle-border-radius: 2px !default;
3939
position: relative;
4040
}
4141

42-
.mat-button-toggle.cdk-focused .mat-button-toggle-focus-overlay {
42+
.mat-button-toggle.cdk-keyboard-focused .mat-button-toggle-focus-overlay {
4343
opacity: 1;
4444
}
4545

src/lib/core/theming/_palette.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ $black-87-opacity: rgba(black, 0.87);
1010
$white-87-opacity: rgba(white, 0.87);
1111
$black-12-opacity: rgba(black, 0.12);
1212
$white-12-opacity: rgba(white, 0.12);
13+
$black-6-opacity: rgba(black, 0.06);
14+
$white-6-opacity: rgba(white, 0.06);
1315

1416
$mat-red: (
1517
50: #ffebee,
@@ -653,7 +655,7 @@ $mat-light-theme-background: (
653655
dialog: white,
654656
disabled-button: $black-12-opacity,
655657
raised-button: white,
656-
dark-overlay: $black-12-opacity,
658+
focused-button: $black-6-opacity,
657659
);
658660

659661
// Background palette for dark themes.
@@ -666,7 +668,7 @@ $mat-dark-theme-background: (
666668
dialog: map_get($mat-grey, 800),
667669
disabled-button: $white-12-opacity,
668670
raised-button: map-get($mat-grey, 800),
669-
dark-overlay: $white-12-opacity,
671+
focused-button: $white-6-opacity,
670672
);
671673

672674
// Foreground palette for light themes.

0 commit comments

Comments
 (0)