Skip to content

fix(material/button): add more prominent focus indication in high contrast mode #20821

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
Oct 20, 2020
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
6 changes: 6 additions & 0 deletions src/material-experimental/mdc-button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
}
}

@include cdk-high-contrast(active, off) {
.mat-mdc-button-base:focus {
outline: solid 3px;
}
}

// Since the stroked button has has an actual border that reduces the available space for
// child elements such as the ripple container or focus overlay, an inherited border radius
// for the absolute-positioned child elements does not work properly. This is because the
Expand Down
20 changes: 6 additions & 14 deletions src/material/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,6 @@
._mat-animation-noopable & {
transition: none;
}

@include cdk-high-contrast(active, off) {
// Note that IE will render this in the same way, no
// matter whether the theme is light or dark. This helps
// with the readability of focused buttons.
background-color: #fff;
}

@include cdk-high-contrast(black-on-white, off) {
// For the black-on-white high contrast mode, the browser will set this element
// to white, making it blend in with the background, hence why we need to set
// it explicitly to black.
background-color: #000;
}
}

// For round buttons, the ripple container should clip child ripples to a circle.
Expand Down Expand Up @@ -171,4 +157,10 @@
.mat-button, .mat-flat-button, .mat-raised-button, .mat-icon-button, .mat-fab, .mat-mini-fab {
outline: solid 1px;
}

.mat-button-base {
&.cdk-keyboard-focused, &.cdk-program-focused {
outline: solid 3px;
}
}
}