Skip to content

Commit

Permalink
fix(select): don't shift arrow if there is no label (#14607)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
crisbeto authored and mmalerba committed Jan 4, 2019
1 parent 65ecb08 commit 7188719
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/lib/form-field/form-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export const MAT_FORM_FIELD_DEFAULT_OPTIONS =
'[class.mat-form-field-invalid]': '_control.errorState',
'[class.mat-form-field-can-float]': '_canLabelFloat',
'[class.mat-form-field-should-float]': '_shouldLabelFloat()',
'[class.mat-form-field-has-label]': '_hasFloatingLabel()',
'[class.mat-form-field-hide-placeholder]': '_hideControlPlaceholder()',
'[class.mat-form-field-disabled]': '_control.disabled',
'[class.mat-form-field-autofilled]': '_control.autofilled',
Expand Down
9 changes: 5 additions & 4 deletions src/lib/select/select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ $mat-select-placeholder-arrow-space: 2 * ($mat-select-arrow-size + $mat-select-a
}

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

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

0 comments on commit 7188719

Please sign in to comment.