Skip to content

fix(material-experimental/mdc-select): fix long labels being incorrectly cut off #21184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/material-experimental/mdc-select/select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ $mat-select-arrow-size: 5px !default;
$mat-select-arrow-margin: 4px !default;
$mat-select-panel-max-height: 256px !default;
$mat-select-placeholder-arrow-space: 2 * ($mat-select-arrow-size + $mat-select-arrow-margin);
$leading-width: 12px !default;
$scale: 0.75 !default;

// We base the select panel styling on top of MDC's menu styles and we
// implement the trigger ourselves since MDC doesn't provide an equivalent.
Expand Down Expand Up @@ -116,3 +118,27 @@ $mat-select-placeholder-arrow-space: 2 * ($mat-select-arrow-size + $mat-select-a
display: block;
}
}

// Our MDC form field implementation is based on the MDC text field which doesn't include styles
// for select. The select specific styles are not present as they don't use their text field as a
// container. Below are the styles to account for the select arrow icon at the end.
.mat-mdc-form-field-type-mat-select {
&.mat-form-field-appearance-fill {
.mdc-floating-label {
max-width: calc(100% - #{$mat-select-placeholder-arrow-space});
}

.mdc-floating-label--float-above {
max-width: calc(100% / #{$scale} - #{$mat-select-placeholder-arrow-space / $scale});
}
}
&.mat-form-field-appearance-outline {
.mdc-notched-outline__notch {
max-width: calc(100% - #{2 * ($mat-select-placeholder-arrow-space + $leading-width)});
}

.mdc-text-field--label-floating .mdc-notched-outline__notch {
max-width: calc(100% - #{$leading-width * 2});
}
}
}