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): buttons in mat-card-actions do not consider its align attribute #20024

Closed
karmasakshi opened this issue Jul 17, 2020 · 1 comment · Fixed by #20040, cayacdev/cashbox#88, ToWipf/jasmarty#155 or CarlosPavajeau/Kaizen#251
Assignees
Labels
area: material/card P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@karmasakshi
Copy link

Reproduction

StackBlitz: https://stackblitz.com/edit/components-issue-ampt5f?file=src%2Fapp%2Fexample-component.css

Steps to reproduce:

  1. Add a card with 2 or more buttons in mat-card-actions
  2. Inspect space between them

Actual behavior

Screenshot 2020-07-17 at 5 40 57 PM

Expected behavior

Screenshot 2020-07-17 at 5 41 45 PM

Proposed fix

Based on align=start or align=end, the first or the last button should be applied the style which is right now applied to the first button regardless:

Screenshot 2020-07-17 at 5 39 30 PM

This can be solved by the following snippet:

.mat-card-actions .mat-button,
.mat-card-actions .mat-raised-button,
.mat-card-actions .mat-stroked-button {
  margin: 0 8px !important;
}

.mat-card-actions[align="end"] .mat-button:last-child,
.mat-card-actions[align="end"] .mat-raised-button:last-child,
.mat-card-actions[align="end"] .mat-stroked-button:last-child {
  margin: 0 !important;
}

.mat-card-actions[align="start"] .mat-button:first-child,
.mat-card-actions[align="start"] .mat-raised-button:first-child,
.mat-card-actions[align="start"] .mat-stroked-button:first-child {
  margin: 0 !important;
}

Similar/related issues I found:

#18391
#13382

Environment

  • Angular: 10
  • CDK/Material: 10
  • Browser(s): Safari, Chrome, Firefox latest
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS
@karmasakshi karmasakshi added the needs triage This issue needs to be triaged by the team label Jul 17, 2020
@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 Jul 19, 2020
@crisbeto crisbeto self-assigned this Jul 19, 2020
crisbeto added a commit to crisbeto/material2 that referenced this issue Jul 19, 2020
We have some styles that clear the margin from the first button, but we didn't apply the same to the last button if the card actions are aligned towards the end.

Fixes angular#20024.
crisbeto added a commit to crisbeto/material2 that referenced this issue Jan 8, 2021
We have some styles that clear the margin from the first button, but we didn't apply the
same to the last button if the card actions are aligned towards the end.

Fixes angular#20024.
annieyw pushed a commit that referenced this issue Mar 7, 2021
…nt (#20040)

We have some styles that clear the margin from the first button, but we didn't apply the
same to the last button if the card actions are aligned towards the end.

Fixes #20024.
annieyw pushed a commit that referenced this issue Mar 7, 2021
…nt (#20040)

We have some styles that clear the margin from the first button, but we didn't apply the
same to the last button if the card actions are aligned towards the end.

Fixes #20024.

(cherry picked from commit 619d591)
@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 Apr 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.