Skip to content

Commit 9a16aa1

Browse files
authored
fix(material/select): fix m3 arrow alignment (#28545)
1 parent 206f0fc commit 9a16aa1

File tree

4 files changed

+24
-26
lines changed

4 files changed

+24
-26
lines changed

src/material-experimental/theming/_m3-density.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,13 @@ $_density-tokens: (
125125
touch-target-display: (block, block, none, none),
126126
),
127127
(mat, ripple): (),
128-
(mat, select): (),
128+
(mat, select): (
129+
arrow-transform: (
130+
translateY(-8px),
131+
translateY(-8px),
132+
none,
133+
),
134+
),
129135
(mat, sidenav): (),
130136
(mat, slide-toggle): (),
131137
(mat, slider): (),

src/material/core/tokens/m2/mat/_select.scss

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
@use 'sass:map';
12
@use '../../token-utils';
23
@use '../../../theming/inspection';
4+
@use '../../../theming/theming';
35
@use '../../../style/sass-utils';
46
@use '@material/elevation/elevation-theme' as mdc-elevation;
57

@@ -46,7 +48,15 @@ $prefix: (mat, select);
4648

4749
// Tokens that can be configured through Angular Material's density theming API.
4850
@function get-density-tokens($theme) {
49-
@return ();
51+
$density-scale: theming.clamp-density(inspection.get-theme-density($theme), -2);
52+
53+
@return (
54+
arrow-transform: map.get((
55+
0: translateY(-8px),
56+
-1: translateY(-8px),
57+
-2: none,
58+
), $density-scale),
59+
);
5060
}
5161

5262
// Combines the tokens generated by the above functions into a single map with placeholder values.

src/material/select/_select-theme.scss

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@use '@material/density' as mdc-density;
2-
@use '@material/textfield' as mdc-textfield;
31
@use '../core/tokens/m2/mat/select' as tokens-mat-select;
42
@use '../core/tokens/token-utils';
53
@use '../core/style/sass-utils';
@@ -71,23 +69,6 @@
7169
@include _theme-from-tokens(inspection.get-theme-tokens($theme, density));
7270
}
7371
@else {
74-
$density-scale: inspection.get-theme-density($theme);
75-
76-
// Density is clamped at -5 here, because MDC's form field throws an error for anything lower.
77-
$form-field-height: mdc-density.prop-value(
78-
$density-config: mdc-textfield.$density-config,
79-
$density-scale: theming.clamp-density($density-scale, -5),
80-
$property-name: height,
81-
);
82-
83-
// On lower densities the filled form field hides its label which causes the label to
84-
// be misaligned. Remove the additional offset that was added because of the label.
85-
@if ($form-field-height < mdc-textfield.$minimum-height-for-filled-label) {
86-
.mat-form-field-appearance-fill .mat-mdc-select-arrow-wrapper {
87-
transform: none;
88-
}
89-
}
90-
9172
@include sass-utils.current-selector-or-root() {
9273
@include token-utils.create-token-values(tokens-mat-select.$prefix,
9374
tokens-mat-select.get-density-tokens($theme));

src/material/select/select.scss

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ $scale: 0.75 !default;
7777
display: inline-flex;
7878
align-items: center;
7979

80-
// When used in a fill appearance with a label, form-field the arrow should be shifted up 8px.
81-
.mat-form-field-appearance-fill & {
82-
transform: translateY(-8px);
83-
}
84-
8580
.mat-form-field-appearance-fill .mdc-text-field--no-label & {
8681
transform: none;
8782
}
@@ -245,3 +240,9 @@ div.mat-mdc-select-panel {
245240
// instead of `opacity` since VoiceOver + Chrome still reads out the space with the latter.
246241
visibility: hidden;
247242
}
243+
244+
@include token-utils.use-tokens(tokens-mat-select.$prefix, tokens-mat-select.get-token-slots()) {
245+
.mat-form-field-appearance-fill .mat-mdc-select-arrow-wrapper {
246+
@include token-utils.create-token-slot(transform, arrow-transform);
247+
}
248+
}

0 commit comments

Comments
 (0)