Skip to content

fix(material/list): checkmark not visible in high contrast mode #29546

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
Aug 7, 2024
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
16 changes: 16 additions & 0 deletions src/material/checkbox/_checkbox-common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@use '@angular/cdk';
@use '../core/tokens/m2/mdc/checkbox' as tokens-mdc-checkbox;
@use '../core/tokens/token-utils';
@use '../core/style/vendor-prefixes';

$_path-length: 29.7833385;
$_transition-duration: 90ms;
Expand Down Expand Up @@ -64,6 +65,10 @@ $_fallback-size: 40px;
.mdc-checkbox--disabled {
cursor: default;
pointer-events: none;

@include cdk.high-contrast(active, off) {
opacity: 0.5;
}
}

.mdc-checkbox__background {
Expand All @@ -82,6 +87,9 @@ $_fallback-size: 40px;
transition: background-color $_transition-duration $_exit-curve,
border-color $_transition-duration $_exit-curve;

// Force browser to show background-color when using the print function
@include vendor-prefixes.color-adjust(exact);

@include token-utils.use-tokens($prefix, $slots) {
$layer-size: token-utils.get-token-variable(state-layer-size, $fallback: $_fallback-size);
$offset: calc((#{$layer-size} - #{$_icon-size}) / 2);
Expand Down Expand Up @@ -167,6 +175,10 @@ $_fallback-size: 40px;
// Always apply the color since the element becomes `opacity: 0`
// when unchecked. This makes the animation look better.
@include token-utils.create-token-slot(color, selected-checkmark-color);

@include cdk.high-contrast(active, off) {
color: CanvasText;
}
}
}

Expand All @@ -175,6 +187,10 @@ $_fallback-size: 40px;
&, &.mat-mdc-checkbox-disabled-interactive {
.mdc-checkbox__checkmark {
@include token-utils.create-token-slot(color, disabled-selected-checkmark-color);

@include cdk.high-contrast(active, off) {
color: CanvasText;
}
}
}
}
Expand Down
18 changes: 0 additions & 18 deletions src/material/checkbox/checkbox.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
@use '@angular/cdk';
@use '../core/style/layout-common';
@use '../core/style/vendor-prefixes';
@use '../core/tokens/m2/mat/checkbox' as tokens-mat-checkbox;
@use '../core/tokens/token-utils';
@use './checkbox-common';
Expand All @@ -17,11 +15,6 @@
// Disable the browser's tap highlight since we indicate state with the ripple instead.
-webkit-tap-highlight-color: transparent;

.mdc-checkbox__background {
// Force browser to show background-color when using the print function
@include vendor-prefixes.color-adjust(exact);
}

// Clicking the label toggles the checkbox, but MDC does not include any styles that inform the
// user of this. Therefore we add the pointer cursor on top of MDC's styles.
label {
Expand Down Expand Up @@ -69,17 +62,6 @@
display: none;
}

@include cdk.high-contrast(active, off) {
&.mat-mdc-checkbox-disabled {
opacity: 0.5;
}

.mdc-checkbox__checkmark {
--mdc-checkbox-selected-checkmark-color: CanvasText;
--mdc-checkbox-disabled-selected-checkmark-color: CanvasText;
}
}

// Apply base styles to the MDC ripple when not hovered, focused, or pressed.
.mdc-checkbox__ripple {
opacity: 0;
Expand Down
Loading