Skip to content

Commit

Permalink
fix(material/select): ensure arrow is centered on all densities
Browse files Browse the repository at this point in the history
On lower densities some form field appearances hide the label which caused the arrow to be misaligned. These changes add an override to center the label again.

Fixes angular#26757.
  • Loading branch information
crisbeto committed May 2, 2023
1 parent abc4940 commit 4ba1d04
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/material/select/_select-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
@use '@material/menu-surface' as mdc-menu-surface;
@use '@material/list/evolution-mixins' as mdc-list;
@use '@material/typography' as mdc-typography;
@use '@material/density' as mdc-density;
@use '@material/textfield' as mdc-textfield;

@use '../core/theming/theming';
@use '../core/typography/typography';
Expand Down Expand Up @@ -79,7 +81,23 @@
}
}

@mixin density($config-or-theme) {}
@mixin density($config-or-theme) {
// Density is clamped at -5, because MDC's form field throws an error for anything lower.
$density-scale: theming.clamp-density(theming.get-density-config($config-or-theme), -5);
$form-field-height: mdc-density.prop-value(
$density-config: mdc-textfield.$density-config,
$density-scale: $density-scale,
$property-name: height,
);

// On lower densities the filled form field hides its label which causes the label to
// be misaligned. Remove the additional offset that was added because of the label.
@if ($form-field-height < mdc-textfield.$minimum-height-for-filled-label) {
.mat-form-field-appearance-fill .mat-mdc-select-arrow-wrapper {
transform: none;
}
}
}

@mixin theme($theme-or-color-config) {
$theme: theming.private-legacy-get-theme($theme-or-color-config);
Expand Down

0 comments on commit 4ba1d04

Please sign in to comment.