Skip to content

Commit 7188719

Browse files
crisbetommalerba
authored andcommitted
fix(select): don't shift arrow if there is no label (#14607)
Currently we move the arrow for a `mat-select` inside a form field up if it has a value, in order to align it in the middle of the field, however doing so when there is no label makes it look off-center. This is visible when using the `standard` appearance inside a `mat-paginator`. These changes only shift the arrow if there's a label. Fixes #13907.
1 parent 65ecb08 commit 7188719

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/lib/form-field/form-field.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export const MAT_FORM_FIELD_DEFAULT_OPTIONS =
121121
'[class.mat-form-field-invalid]': '_control.errorState',
122122
'[class.mat-form-field-can-float]': '_canLabelFloat',
123123
'[class.mat-form-field-should-float]': '_shouldLabelFloat()',
124+
'[class.mat-form-field-has-label]': '_hasFloatingLabel()',
124125
'[class.mat-form-field-hide-placeholder]': '_hideControlPlaceholder()',
125126
'[class.mat-form-field-disabled]': '_control.disabled',
126127
'[class.mat-form-field-autofilled]': '_control.autofilled',

src/lib/select/select.scss

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ $mat-select-placeholder-arrow-space: 2 * ($mat-select-arrow-size + $mat-select-a
5757
}
5858

5959
// When used in a standard appearance form-field the arrow should be shifted up 50%,
60-
// but only if it's not empty
61-
.mat-form-field-appearance-standard .mat-select:not(.mat-select-empty) & {
62-
transform: translateY(-50%);
63-
}
60+
// but only if it's not empty and it has a label.
61+
.mat-form-field-appearance-standard.mat-form-field-has-label
62+
.mat-select:not(.mat-select-empty) & {
63+
transform: translateY(-50%);
64+
}
6465

6566
// Animate the arrow position, but only when the transitioning to empty (animate the arrow down)
6667
// This is in line with the mat-form-field label animation

0 commit comments

Comments
 (0)