Skip to content

fix(material/radio): rendering artifacts at some zoom levels #31612

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
Jul 29, 2025
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/material/radio/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ sass_library(
srcs = ["_radio-common.scss"],
deps = [
":m2",
"//src/cdk:sass_lib",
"//src/material/core/tokens:token_utils",
],
)
Expand Down
79 changes: 59 additions & 20 deletions src/material/radio/_radio-common.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@use '@angular/cdk';
@use './m3-radio';
@use '../core/tokens/token-utils';

Expand Down Expand Up @@ -47,9 +48,14 @@ $fallbacks: m3-radio.get-tokens();
}

&:hover > .mdc-radio__native-control:enabled:checked + .mdc-radio__background {
> .mdc-radio__outer-circle,
$token: 'radio-selected-hover-icon-color';

> .mdc-radio__outer-circle {
border-color: token-utils.slot($token, $fallbacks);
}

> .mdc-radio__inner-circle {
border-color: token-utils.slot(radio-selected-hover-icon-color, $fallbacks);
background-color: token-utils.slot($token, $fallbacks, currentColor);
}
}

Expand All @@ -60,9 +66,14 @@ $fallbacks: m3-radio.get-tokens();
}

&:active > .mdc-radio__native-control:enabled:checked + .mdc-radio__background {
> .mdc-radio__outer-circle,
$token: 'radio-selected-pressed-icon-color';

> .mdc-radio__outer-circle {
border-color: token-utils.slot($token, $fallbacks);
}

> .mdc-radio__inner-circle {
border-color: token-utils.slot(radio-selected-pressed-icon-color, $fallbacks);
background-color: token-utils.slot($token, $fallbacks, currentColor);
}
}
}
Expand Down Expand Up @@ -113,11 +124,16 @@ $fallbacks: m3-radio.get-tokens();
box-sizing: border-box;
width: 100%;
height: 100%;
transform: scale(0, 0);
border-width: 10px;
border-style: solid;
transform: scale(0);
border-radius: 50%;
transition: _exit-transition(transform), _exit-transition(border-color);
transition: _exit-transition(transform), _exit-transition(background-color);

@include cdk.high-contrast {
// Override the color, because solid colors don't show up by default in
// high contrast mode. We need !important here, because the various state
// selectors are really specific and duplicating them will be brittle.
background-color: CanvasText !important;
}
}

.mdc-radio__native-control {
Expand All @@ -142,7 +158,7 @@ $fallbacks: m3-radio.get-tokens();
}

> .mdc-radio__inner-circle {
transition: _enter-transition(transform), _enter-transition(border-color);
transition: _enter-transition(transform), _enter-transition(background-color);
}
}
}
Expand All @@ -162,12 +178,18 @@ $fallbacks: m3-radio.get-tokens();
}

+ .mdc-radio__background {
$color-token: 'radio-disabled-selected-icon-color';
$opacity-token: token-utils.slot(radio-disabled-selected-icon-opacity, $fallbacks);
cursor: default;

> .mdc-radio__inner-circle,
> .mdc-radio__outer-circle {
border-color: token-utils.slot(radio-disabled-selected-icon-color, $fallbacks);
opacity: token-utils.slot(radio-disabled-selected-icon-opacity, $fallbacks);
border-color: token-utils.slot($color-token, $fallbacks);
opacity: $opacity-token;
}

> .mdc-radio__inner-circle {
background-color: token-utils.slot($color-token, $fallbacks, currentColor);
opacity: $opacity-token;
}
}
}
Expand All @@ -178,25 +200,35 @@ $fallbacks: m3-radio.get-tokens();
}

&:checked + .mdc-radio__background {
> .mdc-radio__outer-circle,
$token: 'radio-selected-icon-color';

> .mdc-radio__outer-circle {
border-color: token-utils.slot($token, $fallbacks);
}

> .mdc-radio__inner-circle {
border-color: token-utils.slot(radio-selected-icon-color, $fallbacks);
background-color: token-utils.slot($token, $fallbacks, currentColor);
}
}

@if ($is-interactive) {
&:focus:checked + .mdc-radio__background {
> .mdc-radio__inner-circle,
$token: 'radio-selected-focus-icon-color';

> .mdc-radio__outer-circle {
border-color: token-utils.slot(radio-selected-focus-icon-color, $fallbacks);
border-color: token-utils.slot($token, $fallbacks);
}

> .mdc-radio__inner-circle {
background-color: token-utils.slot($token, $fallbacks, currentColor);
}
}
}
}

&:checked + .mdc-radio__background > .mdc-radio__inner-circle {
transform: scale(0.5);
transition: _enter-transition(transform), _enter-transition(border-color);
transition: _enter-transition(transform), _enter-transition(background-color);
}
}

Expand All @@ -215,10 +247,17 @@ $fallbacks: m3-radio.get-tokens();
&:hover .mdc-radio__native-control:checked + .mdc-radio__background,
.mdc-radio__native-control:checked:focus + .mdc-radio__background,
.mdc-radio__native-control + .mdc-radio__background {
> .mdc-radio__inner-circle,
$color-token: 'radio-disabled-selected-icon-color';
$opacity-token: token-utils.slot(radio-disabled-selected-icon-opacity, $fallbacks);

> .mdc-radio__outer-circle {
border-color: token-utils.slot(radio-disabled-selected-icon-color, $fallbacks);
opacity: token-utils.slot(radio-disabled-selected-icon-opacity, $fallbacks);
border-color: token-utils.slot($color-token, $fallbacks);
opacity: $opacity-token;
}

> .mdc-radio__inner-circle {
background-color: token-utils.slot($color-token, $fallbacks, currentColor);
opacity: $opacity-token;
}
}
}
Expand Down
Loading