Skip to content

Commit

Permalink
fix(material-experimental/mdc-select): arrow not rendering in high co…
Browse files Browse the repository at this point in the history
…ntrast mode (#21606)

The MDC select uses a CSS triangle for its down arrow which renders as a rectangle in
high contrast mode. These changes switch it to an SVG arrow.

These changes are identical to #14219 which had some trouble landing due to screenshot
diffs. The MDC select shouldn't have such issues.

Relates to #21263.

(cherry picked from commit fef9179)
  • Loading branch information
crisbeto authored and annieyw committed Mar 7, 2021
1 parent 4d45db7 commit 0f333a2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
9 changes: 8 additions & 1 deletion src/material-experimental/mdc-select/select.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@
</span>
</div>

<div class="mat-mdc-select-arrow-wrapper"><div class="mat-mdc-select-arrow"></div></div>
<div class="mat-mdc-select-arrow-wrapper">
<div class="mat-mdc-select-arrow">
<!-- Use an inline SVG, because it works better than a CSS triangle in high contrast mode. -->
<svg viewBox="0 0 24 24" width="24px" height="24px" focusable="false">
<path d="M7 10l5 5 5-5z"/>
</svg>
</div>
</div>
</div>

<ng-template
Expand Down
16 changes: 11 additions & 5 deletions src/material-experimental/mdc-select/select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,18 @@ $scale: 0.75 !default;
}

.mat-mdc-select-arrow {
width: 0;
height: 0;
border-left: $mat-select-arrow-size solid transparent;
border-right: $mat-select-arrow-size solid transparent;
border-top: $mat-select-arrow-size solid;
margin: 0 $mat-select-arrow-margin;
width: $mat-select-arrow-size * 2;
height: $mat-select-arrow-size;
position: relative;

svg {
fill: currentColor;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}

// Note that the `.mdc-menu-surface` is here in order to bump up the specificity
Expand Down

0 comments on commit 0f333a2

Please sign in to comment.