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(mat-card): Picture elements on mat-cards have incorrect top-margin, when no heading is present #23649

Closed
Trombach opened this issue Sep 28, 2021 · 3 comments · Fixed by #23678
Assignees
Labels
area: material/card P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@Trombach
Copy link

Reproduction

Use StackBlitz to reproduce your issue:
https://stackblitz.com/edit/components-issue-5lp7n2?file=src/app/example-component.html

Steps to reproduce:

  1. Create a <mat-card> element with no title, or subtitle
  2. Add a <picture> element with at least one <source> element
<mat-card>
  <picture>
    <source
      srcset="https://material.angular.io/assets/img/examples/shiba2.jpg"
    />
    <img mat-card-image />
  </picture>
</mat-card>

Expected Behavior

What behavior were you expecting to see?

The top of the image should be flush with the top edge of the card, just like when using an <img/> tag

Actual Behavior

What behavior did you actually see?

There was a gap between the top edge of the card and the image. This is due to how the css class that overwrites the padding of the card is applied here.

Environment

  • Angular:
  • CDK/Material: 12.2.7
  • Browser(s): Chrome 94, Safari 15
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS
@Trombach Trombach added the needs triage This issue needs to be triaged by the team label Sep 28, 2021
@Trombach Trombach changed the title bug(COMPONENT): Picture elements on mat-cards have incorrect top-margin, when no heading is present bug(mat-card): Picture elements on mat-cards have incorrect top-margin, when no heading is present Sep 28, 2021
@crisbeto crisbeto added area: material/card P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed needs triage This issue needs to be triaged by the team labels Sep 28, 2021
@crisbeto crisbeto self-assigned this Oct 2, 2021
@crisbeto crisbeto added the has pr label Oct 2, 2021
crisbeto added a commit to crisbeto/material2 that referenced this issue Oct 2, 2021
Fixes that setting `mat-card-image` on a `picture` element doesn't work correctly.

Fixes angular#23649.
@crisbeto
Copy link
Member

crisbeto commented Oct 2, 2021

I've submitted #23678 to fix it. Note that you'll also have to move the mat-card-image attribute to the picture element itself.

@Trombach
Copy link
Author

Trombach commented Oct 4, 2021

@crisbeto Thanks for the quick fix! Much appreciated

crisbeto added a commit to crisbeto/material2 that referenced this issue Oct 10, 2021
Fixes that setting `mat-card-image` on a `picture` element doesn't work correctly.

Fixes angular#23649.
andrewseguin pushed a commit that referenced this issue Jan 18, 2022
Fixes that setting `mat-card-image` on a `picture` element doesn't work correctly.

Fixes #23649.
andrewseguin pushed a commit that referenced this issue Jan 18, 2022
Fixes that setting `mat-card-image` on a `picture` element doesn't work correctly.

Fixes #23649.

(cherry picked from commit 267b03a)
@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 Feb 18, 2022
forsti0506 pushed a commit to forsti0506/components that referenced this issue Apr 3, 2022
…#23678)

Fixes that setting `mat-card-image` on a `picture` element doesn't work correctly.

Fixes angular#23649.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/card 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