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

Allow specifying number of lines in a mat-list-item #15466

Closed
calebegg opened this issue Mar 13, 2019 · 3 comments · Fixed by #15552
Closed

Allow specifying number of lines in a mat-list-item #15466

calebegg opened this issue Mar 13, 2019 · 3 comments · Fixed by #15552
Assignees
Labels
G This is is related to a Google internal issue P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@calebegg
Copy link
Member

The framework tries to be clever and count the mat-line children to determine whether to put mat-2-line and mat-3-line classes on a mat-list-item. Sometimes, though, the real contents is too complex to have top-level mat-line items, and I just want to specify that I want the mat-3-line styling. However, if I add this class myself, Angular helpfully removes it :/

It'd be great to be able to specify this somehow, possibly just through the class, or through a mat-3-line directive.

Right now, my workaround is to put some empty divs in like:

  <div mat-line></div>
  <div mat-line></div>
  <div mat-line></div>
@crisbeto
Copy link
Member

@calebegg can you post what your template looks like? Rather than adding a separate API, it might make sense to mark our query as descendants: true so that it picks up all descendant items, rather than just the direct ones.

@calebegg
Copy link
Member Author

calebegg commented Mar 20, 2019

Oh, that would work. I didn't know it would be that easy.

It's basically something like:

<mat-list-item>
  <div class="left">
    <h3 mat-line>foo</h3>
    <p mat-line>detail</p>
  </div>
  <div class="right">
    <div>timestamp</div>
    <div>status</div>
  </div>
  <div class="actions">
    <button mat-icon-button>...</button>
  </div>
</mat-list-item>

I'd be tempted to put mat-line on the timestamp and status divs as well if I didn't understand how it worked, so I'm not sure if it's exactly clear what's happening, but it would definitely solve the issue for me and I think it would be an improvement over what we have now.

@crisbeto crisbeto self-assigned this Mar 20, 2019
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent has pr G This is is related to a Google internal issue labels Mar 20, 2019
crisbeto added a commit to crisbeto/material2 that referenced this issue Mar 20, 2019
Fixes the `mat-list-item` not picking up `mat-line`, if it's not a direct descendant.

Fixes angular#15466.
jelbourn pushed a commit that referenced this issue Mar 26, 2019
Fixes the `mat-list-item` not picking up `mat-line`, if it's not a direct descendant.

Fixes #15466.
mmalerba pushed a commit that referenced this issue Apr 3, 2019
Fixes the `mat-list-item` not picking up `mat-line`, if it's not a direct descendant.

Fixes #15466.
mmalerba pushed a commit that referenced this issue Apr 3, 2019
Fixes the `mat-list-item` not picking up `mat-line`, if it's not a direct descendant.

Fixes #15466.
mmalerba pushed a commit to crisbeto/material2 that referenced this issue Apr 5, 2019
Fixes the `mat-list-item` not picking up `mat-line`, if it's not a direct descendant.

Fixes angular#15466.
mmalerba pushed a commit that referenced this issue Apr 5, 2019
Fixes the `mat-list-item` not picking up `mat-line`, if it's not a direct descendant.

Fixes #15466.
@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 Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
G This is is related to a Google internal issue P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants