Skip to content

Commit 570e235

Browse files
crisbetojelbourn
authored andcommitted
fix(select): option not truncated correctly in multiple mode
Currently, when the text of an option is truncated, it ends up removing everything except the ellipsis on Firefox, IE and Edge. These changes fix the truncation and simplify the option view. Relates to #7211.
1 parent 8b3c8a5 commit 570e235

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class SelectDemo {
5252
{value: 'charizard-1', viewValue: 'Charizard'},
5353
{value: 'squirtle-2', viewValue: 'Squirtle'},
5454
{value: 'pikachu-3', viewValue: 'Pikachu'},
55-
{value: 'eevee-4', viewValue: 'Eevee'},
55+
{value: 'jigglypuff-4', viewValue: 'Jigglypuff with a really long name that will truncate'},
5656
{value: 'ditto-5', viewValue: 'Ditto'},
5757
{value: 'psyduck-6', viewValue: 'Psyduck'},
5858
];
@@ -112,7 +112,7 @@ export class SelectDemo {
112112
}
113113

114114
setPokemonValue() {
115-
this.currentPokemon = ['eevee-4', 'psyduck-6'];
115+
this.currentPokemon = ['jigglypuff-4', 'psyduck-6'];
116116
}
117117

118118
reassignDrinkByCopy() {

src/lib/core/option/_option.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
position: relative;
1414
cursor: pointer;
1515
outline: none;
16+
display: flex;
17+
flex-direction: row;
18+
max-width: 100%;
19+
box-sizing: border-box;
20+
align-items: center;
1621

1722
&[aria-disabled='true'] {
1823
@include user-select(none);
@@ -35,6 +40,9 @@
3540
// </mat-option>
3641
.mat-option-text {
3742
display: inline-block;
43+
flex-grow: 1;
44+
overflow: hidden;
45+
text-overflow: ellipsis;
3846
}
3947

4048
.mat-option-ripple {

src/lib/core/option/option.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
<span *ngIf="multiple">
2-
<mat-pseudo-checkbox class="mat-option-pseudo-checkbox"
3-
[state]="selected ? 'checked' : ''" [disabled]="disabled"></mat-pseudo-checkbox>
4-
</span>
1+
<mat-pseudo-checkbox *ngIf="multiple" class="mat-option-pseudo-checkbox"
2+
[state]="selected ? 'checked' : ''" [disabled]="disabled"></mat-pseudo-checkbox>
53

64
<span class="mat-option-text"><ng-content></ng-content></span>
75

0 commit comments

Comments
 (0)