Skip to content
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

bug(matLine): Using matLine within MatListItem squishes buttons #19809

Open
wakonp opened this issue Jun 30, 2020 · 2 comments
Open

bug(matLine): Using matLine within MatListItem squishes buttons #19809

wakonp opened this issue Jun 30, 2020 · 2 comments
Labels
area: material/list P4 A relatively minor issue that is not relevant to core functions

Comments

@wakonp
Copy link

wakonp commented Jun 30, 2020

Reproduction

Use StackBlitz to reproduce my issue: https://components-issue-raav17.stackblitz.io

Steps to reproduce:

  1. Generate Angular Project
  2. Install newest Version of Material ( "@angular/material": "^10.0.0",)
  3. Create a MatList with MatListItems
  4. Use the matLine Component (Directive) within a span and add a button too
  5. Create a new MatListItem without the matLine Directive and a
    between the span and the button

Expected Behavior

In the StackBlitz Example the Button of the second MatListItem should get displayed as the first one.

Actual Behavior

In the StackBlitz Example the Button of the second MatListItem gets squished.

Environment

  • Angular: "@angular/core": "~10.0.0", "@angular/cli": "~10.0.0",...
  • CDK/Material: "@angular/material": "^10.0.0", "@angular/cdk": "^10.0.0",
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows
    image
    image
@wakonp wakonp added the needs triage This issue needs to be triaged by the team label Jun 30, 2020
@wakonp wakonp changed the title matLine with Button Using matLine within MatListItem squishes buttons Jun 30, 2020
@wakonp wakonp changed the title Using matLine within MatListItem squishes buttons bug(matLine): Using matLine within MatListItem squishes buttons Jun 30, 2020
@swseverance
Copy link
Contributor

Hi @wakonp I don't believe this is actually a bug. The matLine directive is used for lists that require multiple lines be displayed per item, and the directive should be added to each line. See documentation. If you want all of the list item content to be displayed on one line you should probably avoid using the matLine directive. If you want each element on a separate line you can try:

  <mat-list-item>
    <span matLine>Do Something else</span>
    <button matLine mat-raised-button color="accent">Foo is cool</button>
  </mat-list-item>

If you are satisfied can you please close the issue? Thanks!

@wakonp
Copy link
Author

wakonp commented Jul 1, 2020

The matLine directive is used for lists that require multiple lines be displayed per item, and the directive should be added to each line

I am sorry but I think if that is correct, your documentation is wrong or there should be two types of matLine Directive. As you can see in your MatNavList, which is basically a MatList (correct me if am wrong with this statement), the matLine within an a Element is used to display the mat-icon-button at the end of the same line.

image

I think the matLine directive has multiple purposes, which i also displayed here https://components-issue-4qxcyg.stackblitz.io:
image

  1. Ellipsis Effect - if the text-content of the element gets too large (if you open the stackblitz - pls resize your browser)
  2. For displaying multiple lines (as you replied before) + adding the ellipsis Effect
  3. For displaying "complex" structure

I know how I can get arround the problem and I know it isn't really a bug, but I think it is inconsistend.

swseverance pushed a commit to swseverance/material2 that referenced this issue Jul 1, 2020
* use `flex: auto` instead of `width: 100%` to allow `.mat-list-text`
  element to take up the available space
swseverance pushed a commit to swseverance/material2 that referenced this issue Jul 1, 2020
* use `flex: auto` instead of `width: 100%` to allow `.mat-list-text`
  element to take up the available space
swseverance pushed a commit to swseverance/material2 that referenced this issue Jul 1, 2020
)

Use `flex: auto` instead of `width: 100%` to size `.mat-list-text` elements. using `width: 100%` can lead to `.mat-list-text` sibling elements shrinking and having their content overflow.
@crisbeto crisbeto added area: material/list has pr P4 A relatively minor issue that is not relevant to core functions and removed needs triage This issue needs to be triaged by the team labels Jul 3, 2020
mmalerba pushed a commit that referenced this issue Jul 7, 2020
Use `flex: auto` instead of `width: 100%` to size `.mat-list-text` elements. using `width: 100%` can lead to `.mat-list-text` sibling elements shrinking and having their content overflow.
mmalerba pushed a commit that referenced this issue Jul 11, 2020
…19819)

Use `flex: auto` instead of `width: 100%` to size `.mat-list-text` elements. using `width: 100%` can lead to `.mat-list-text` sibling elements shrinking and having their content overflow.
mmalerba pushed a commit that referenced this issue Jul 11, 2020
…19819)

Use `flex: auto` instead of `width: 100%` to size `.mat-list-text` elements. using `width: 100%` can lead to `.mat-list-text` sibling elements shrinking and having their content overflow.
@mmalerba mmalerba removed the has pr label Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/list P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

No branches or pull requests

4 participants