Skip to content

Commit bca3c5b

Browse files
committed
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 40d6bcb commit bca3c5b

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
@@ -60,7 +60,7 @@ export class SelectDemo {
6060
{value: 'charizard-1', viewValue: 'Charizard'},
6161
{value: 'squirtle-2', viewValue: 'Squirtle'},
6262
{value: 'pikachu-3', viewValue: 'Pikachu'},
63-
{value: 'eevee-4', viewValue: 'Eevee'},
63+
{value: 'jigglypuff-4', viewValue: 'Jigglypuff with a really long name that will truncate'},
6464
{value: 'ditto-5', viewValue: 'Ditto'},
6565
{value: 'psyduck-6', viewValue: 'Psyduck'},
6666
];
@@ -120,7 +120,7 @@ export class SelectDemo {
120120
}
121121

122122
setPokemonValue() {
123-
this.currentPokemon = ['eevee-4', 'psyduck-6'];
123+
this.currentPokemon = ['jigglypuff-4', 'psyduck-6'];
124124
}
125125

126126
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)