Skip to content

Commit 9e11f60

Browse files
committed
fix(material/select): mat-select-arrow not rotating when dropdown is open
fixes mat-select not rotating when dropdown menu is visible. fixes case #29985
1 parent 17ff5be commit 9e11f60

File tree

2 files changed

+30
-25
lines changed

2 files changed

+30
-25
lines changed

src/material/select/select.html

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<div cdk-overlay-origin
2-
class="mat-mdc-select-trigger"
3-
(click)="open()"
4-
#fallbackOverlayOrigin="cdkOverlayOrigin"
5-
#trigger>
6-
1+
<div
2+
cdk-overlay-origin
3+
class="mat-mdc-select-trigger"
4+
(click)="open()"
5+
#fallbackOverlayOrigin="cdkOverlayOrigin"
6+
#trigger
7+
>
78
<div class="mat-mdc-select-value" [attr.id]="_valueId">
89
@if (empty) {
910
<span class="mat-mdc-select-placeholder mat-mdc-select-min-line">{{placeholder}}</span>
@@ -21,8 +22,15 @@
2122
<div class="mat-mdc-select-arrow-wrapper">
2223
<div class="mat-mdc-select-arrow">
2324
<!-- Use an inline SVG, because it works better than a CSS triangle in high contrast mode. -->
24-
<svg viewBox="0 0 24 24" width="24px" height="24px" focusable="false" aria-hidden="true">
25-
<path d="M7 10l5 5 5-5z"/>
25+
<svg
26+
viewBox="0 0 24 24"
27+
width="24px"
28+
height="24px"
29+
focusable="false"
30+
aria-hidden="true"
31+
[ngClass]="{'mat-mdc-select-svg-opened': panelOpen}"
32+
>
33+
<path d="M7 10l5 5 5-5z" />
2634
</svg>
2735
</div>
2836
</div>
@@ -41,7 +49,8 @@
4149
[cdkConnectedOverlayWidth]="_overlayWidth"
4250
(backdropClick)="close()"
4351
(attach)="_onAttached()"
44-
(detach)="close()">
52+
(detach)="close()"
53+
>
4554
<div
4655
#panel
4756
role="listbox"
@@ -54,7 +63,8 @@
5463
[ngClass]="panelClass"
5564
[@transformPanel]="'showing'"
5665
(@transformPanel.done)="_panelDoneAnimatingStream.next($event.toState)"
57-
(keydown)="_handleKeydown($event)">
66+
(keydown)="_handleKeydown($event)"
67+
>
5868
<ng-content></ng-content>
5969
</div>
6070
</ng-template>

src/material/select/select.scss

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,16 @@
88
$mat-select-arrow-size: 5px !default;
99
$mat-select-arrow-margin: 4px !default;
1010
$mat-select-panel-max-height: 275px !default;
11-
$mat-select-placeholder-arrow-space: 2 *
12-
($mat-select-arrow-size + $mat-select-arrow-margin);
11+
$mat-select-placeholder-arrow-space: 2 * ($mat-select-arrow-size + $mat-select-arrow-margin);
1312
$leading-width: 12px !default;
1413
$scale: 0.75 !default;
1514

16-
1715
.mat-mdc-select {
1816
display: inline-block;
1917
width: 100%;
2018
outline: none;
2119

22-
@include token-utils.use-tokens(
23-
tokens-mat-select.$prefix, tokens-mat-select.get-token-slots()) {
20+
@include token-utils.use-tokens(tokens-mat-select.$prefix, tokens-mat-select.get-token-slots()) {
2421
@include vendor-prefixes.smooth-font();
2522
@include token-utils.create-token-slot(color, enabled-trigger-text-color);
2623
@include token-utils.create-token-slot(font-family, trigger-text-font);
@@ -37,8 +34,7 @@ $scale: 0.75 !default;
3734
}
3835

3936
.mat-mdc-select-disabled {
40-
@include token-utils.use-tokens(
41-
tokens-mat-select.$prefix, tokens-mat-select.get-token-slots()) {
37+
@include token-utils.use-tokens(tokens-mat-select.$prefix, tokens-mat-select.get-token-slots()) {
4238
@include token-utils.create-token-slot(color, disabled-trigger-text-color);
4339
}
4440
}
@@ -93,8 +89,7 @@ $scale: 0.75 !default;
9389
height: $mat-select-arrow-size;
9490
position: relative;
9591

96-
@include token-utils.use-tokens(
97-
tokens-mat-select.$prefix, tokens-mat-select.get-token-slots()) {
92+
@include token-utils.use-tokens(tokens-mat-select.$prefix, tokens-mat-select.get-token-slots()) {
9893
@include token-utils.create-token-slot(color, enabled-arrow-color);
9994

10095
.mat-mdc-form-field.mat-focused & {
@@ -122,6 +117,9 @@ $scale: 0.75 !default;
122117
fill: GrayText;
123118
}
124119
}
120+
&.mat-mdc-select-svg-opened {
121+
transform: translate(-50%, -50%) rotate(180deg);
122+
}
125123
}
126124
}
127125

@@ -140,8 +138,7 @@ div.mat-mdc-select-panel {
140138
// Workaround in case other MDC menu surface styles bleed in.
141139
position: static;
142140

143-
@include token-utils.use-tokens(
144-
tokens-mat-select.$prefix, tokens-mat-select.get-token-slots()) {
141+
@include token-utils.use-tokens(tokens-mat-select.$prefix, tokens-mat-select.get-token-slots()) {
145142
@include token-utils.create-token-slot(background-color, panel-background-color);
146143
}
147144

@@ -170,11 +167,9 @@ div.mat-mdc-select-panel {
170167
// Delay the transition until the label has animated about a third of the way through, in
171168
// order to prevent the placeholder from overlapping for a split second.
172169
transition: color variables.$swift-ease-out-duration
173-
math.div(variables.$swift-ease-out-duration, 3)
174-
variables.$swift-ease-out-timing-function;
170+
math.div(variables.$swift-ease-out-duration, 3) variables.$swift-ease-out-timing-function;
175171

176-
@include token-utils.use-tokens(
177-
tokens-mat-select.$prefix, tokens-mat-select.get-token-slots()) {
172+
@include token-utils.use-tokens(tokens-mat-select.$prefix, tokens-mat-select.get-token-slots()) {
178173
@include token-utils.create-token-slot(color, placeholder-text-color);
179174
}
180175

0 commit comments

Comments
 (0)