Skip to content

Commit 5f773b2

Browse files
committed
fix(material-experimental/mdc-radio): add hover indication
Fixes that the MDC-based radio button doesn't have hover indication, because it usually comes from the MDC ripple which we don't use.
1 parent cbef92a commit 5f773b2

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/material-experimental/mdc-radio/_radio-theme.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
));
1717

1818
// TODO(crisbeto): this should be included by MDC's `theme-styles`, but it isn't currently.
19-
@include mdc-radio-theme.focus-indicator-color($color-palette);
19+
&.mat-mdc-radio-checked {
20+
@include mdc-radio-theme.focus-indicator-color($color-palette);
21+
}
2022
}
2123

2224
@mixin color($config-or-theme) {
@@ -30,6 +32,7 @@
3032

3133
.mat-mdc-radio-button {
3234
@include mdc-form-field.core-styles($query: mdc-helpers.$mat-theme-styles-query);
35+
@include mdc-radio-theme.focus-indicator-color(mdc-theme-color.prop-value(on-surface));
3336
@include mdc-radio-theme.theme((
3437
// The disabled colors don't use the `rgba` version, because
3538
// MDC applies a separate opacity to disabled buttons.

src/material-experimental/mdc-radio/radio.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@use '@material/radio/radio-theme' as mdc-radio-theme;
44
@use '@material/form-field' as mdc-form-field;
55
@use '@material/touch-target' as mdc-touch-target;
6+
@use '@material/ripple' as mdc-ripple;
67
@use '../mdc-helpers/mdc-helpers';
78
@use '../../cdk/a11y';
89
@use '../../material/core/style/layout-common';
@@ -34,6 +35,13 @@
3435
unselected-pressed-state-layer-opacity: null,
3536
)));
3637
}
38+
39+
&:hover .mdc-radio__native-control:not([disabled]):not(:focus) {
40+
& ~ .mdc-radio__background::before {
41+
opacity: map.get(mdc-ripple.$dark-ink-opacities, hover);
42+
transform: scale(1);
43+
}
44+
}
3745
}
3846

3947
// This is necessary because we do not depend on MDC's ripple, but have our own that should be

src/material-experimental/mdc-radio/radio.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export class MatRadioGroup extends _MatRadioGroupBase<MatRadioButton> {
9090
'[class.mat-primary]': 'color === "primary"',
9191
'[class.mat-accent]': 'color === "accent"',
9292
'[class.mat-warn]': 'color === "warn"',
93+
'[class.mat-mdc-radio-checked]': 'checked',
9394
'[class._mat-animation-noopable]': '_noopAnimations',
9495
// Needs to be removed since it causes some a11y issues (see #21266).
9596
'[attr.tabindex]': 'null',

0 commit comments

Comments
 (0)