Skip to content

MatSelect: Long options are truncated #7211

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

Closed
jermowery opened this issue Sep 20, 2017 · 12 comments
Closed

MatSelect: Long options are truncated #7211

jermowery opened this issue Sep 20, 2017 · 12 comments
Assignees
Labels
area: material/select G This is is related to a Google internal issue P2 The issue is important to a large percentage of users, with a workaround

Comments

@jermowery
Copy link
Contributor

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Options should wrap or be shown in some way that does not hide the option text from the user.

What is the current behavior?

Long option text is truncated.

What are the steps to reproduce?

http://plnkr.co/edit/X8JZAatPpRD6RBSRgT7K?p=preview

What is the use-case or motivation for changing an existing behavior?

Text can be long in options, the user should not have the option text hidden from them.
For translated text that is longer than the source text this can happen more frequently.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Latest

Is there anything else we should know?

@fxck
Copy link
Contributor

fxck commented Sep 21, 2017

related #3883

@josephperrott josephperrott added P2 The issue is important to a large percentage of users, with a workaround Accessibility This issue is related to accessibility (a11y) G This is is related to a Google internal issue labels Sep 25, 2017
@dixy
Copy link

dixy commented Oct 17, 2017

In a select in multiple selection mode, the option text is entirely hidden for long options on at least Firefox and IE 11.

firefox-56
Firefox 56

chrome-61
Chrome 61 is almost good (two dots hidden)

crisbeto added a commit to crisbeto/material2 that referenced this issue Oct 17, 2017
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 angular#7211.
@crisbeto
Copy link
Member

That is a separate issue from the one being discussed here @dixy, but thanks for the report. It should be fixed by #7857.

jelbourn pushed a commit that referenced this issue Nov 19, 2017
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.
crisbeto added a commit to crisbeto/material2 that referenced this issue Nov 19, 2017
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 angular#7211.
crisbeto added a commit to crisbeto/material2 that referenced this issue Nov 20, 2017
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 angular#7211.
tinayuangao pushed a commit that referenced this issue Dec 1, 2017
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.
@UncleJimmy
Copy link

I want to add a tooltip on this "mat-option-text" as workaround, is there any way we could know the text is truncated or not?

@Hydhen
Copy link

Hydhen commented Feb 28, 2019

@UncleJimmy I've seen this workaround :

function isEllipsisActive(e) {
     return (e.offsetWidth < e.scrollWidth);
}

From this link

But I didn't succeeded on getting the propeties from an element node, i'm stuck to this point :

@ViewChild('select') select: MatSelect;
this.select.options.forEach((option: MatOption) => {
     console.log(option._getHostElement().childNodes[1]); // Gives the span element
});

@Hydhen
Copy link

Hydhen commented Feb 28, 2019

Just find out you can do this :

<mat-option *ngFor="let obj of objs" [value]="obj.Code" matTooltip="{{ obj.Value }}"
      matTooltipPosition="before" matTooltipDisabled="{{ obj.Value.length < 25 }}">
      {{ obj.Value }}
</mat-option>

It works well, but it evaluates according to the number of caracters and not if the text is ellipsed or not

@jelbourn
Copy link
Member

The MDC-based version of MatSelect wraps option text:
https://stackblitz.com/edit/angular-mdc-issue-md2tzg?file=src%2Fapp%2Fexample-component.html

This is in material-experimental now and will eventually replace the existing MatSelect

@jelbourn jelbourn added Fixed in MDC and removed Accessibility This issue is related to accessibility (a11y) labels Nov 25, 2020
@jelbourn jelbourn changed the title [md-select] Long options are truncated MatSelect: Long options are truncated Nov 25, 2020
@adityakmehta
Copy link

@oleg-golota
Copy link

I also need this bug #10038 to be fixed. I wonder why it was closed?

@Totati
Copy link
Contributor

Totati commented Nov 15, 2021

It was marked as duplicate.

@amysorto
Copy link
Contributor

amysorto commented Nov 2, 2022

Text wraps instead of truncating in the MDC based select component coming soon in v15, I am closing this bug.

@amysorto amysorto closed this as completed Nov 2, 2022
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/select G This is is related to a Google internal issue P2 The issue is important to a large percentage of users, with a workaround
Projects
None yet
Development

No branches or pull requests