Skip to content

Commit 416f56f

Browse files
crisbetommalerba
authored andcommitted
fix(select): trim long labels inside md-option (#2444)
* fix(select): not trimming long labels * Fixes long text not being trimmed inside of `md-option`, because the element is a flex container. Switches it to `display: block` and uses `line-height` to center the text. * Fixes the selected value not being trimmed, because the element doesn't have a defined width. Fixes #2440. * fix: menu icon alignment
1 parent 5def001 commit 416f56f

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

src/demo-app/select/select-demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class SelectDemo {
2424

2525
drinks = [
2626
{value: 'coke-0', viewValue: 'Coke'},
27-
{value: 'sprite-1', viewValue: 'Sprite'},
27+
{value: 'long-name-1', viewValue: 'Decaf Chocolate Brownie Vanilla Gingerbread Frappuccino'},
2828
{value: 'water-2', viewValue: 'Water'},
2929
{value: 'pepper-3', viewValue: 'Dr. Pepper'},
3030
{value: 'coffee-4', viewValue: 'Coffee'},

src/lib/core/style/_menu-common.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ $md-menu-side-padding: 16px !default;
2424
@mixin md-menu-item-base() {
2525
@include md-truncate-line();
2626

27-
display: flex;
28-
flex-direction: row;
29-
align-items: center;
27+
// Needs to be a block for the ellipsis to work.
28+
display: block;
29+
line-height: $md-menu-item-height;
3030
height: $md-menu-item-height;
3131
padding: 0 $md-menu-side-padding;
3232

src/lib/menu/_menu-theme.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
md-icon {
2222
color: md-color($foreground, 'icon');
23+
vertical-align: middle;
2324
}
2425

2526
&:hover:not([disabled]), &:focus:not([disabled]) {

src/lib/select/select.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ md-select {
6565
}
6666

6767
.md-select-value {
68-
position: absolute;
6968
@include md-truncate-line();
69+
position: absolute;
70+
max-width: calc(100% - #{$md-select-arrow-size * 2});
7071

7172
// Firefox and some versions of IE incorrectly keep absolutely
7273
// positioned children of flex containers in the flex flow when calculating

0 commit comments

Comments
 (0)