Skip to content

MatSelect: Long options are truncated #7211

Closed

Description

@jermowery

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?

Activity

  1. fxck commented on Sep 21, 2017

    @fxck
    Contributor

    related #3883

  2. added
    P2
    Accessibility
    G
    on Sep 25, 2017
  3. dixy commented on Oct 17, 2017

    @dixy

    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)

  4. crisbeto commented on Oct 17, 2017

    @crisbeto
    Member

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

  5. UncleJimmy commented on Mar 8, 2018

    @UncleJimmy

    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?

  6. Hydhen commented on Feb 28, 2019

    @Hydhen

    @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
    });
    
  7. Hydhen commented on Feb 28, 2019

    @Hydhen

    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

  8. jelbourn commented on Nov 25, 2020

    @jelbourn
    Contributor

    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

  9. added and removed
    Accessibility
    on Nov 25, 2020
  10. changed the title [-][md-select] Long options are truncated[/-] [+]MatSelect: Long options are truncated[/+] on Nov 25, 2020
  11. oleg-golota commented on Nov 15, 2021

    @oleg-golota

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

  12. Totati commented on Nov 15, 2021

    @Totati
    Contributor

    It was marked as duplicate.

  13. amysorto commented on Nov 2, 2022

    @amysorto
    Contributor

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

  14. angular-automatic-lock-bot commented on Dec 3, 2022

    @angular-automatic-lock-bot

    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.

  15. locked and limited conversation to collaborators on Dec 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GP2area: material/select

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions