angular / angular/components

bug(material/button): incorrect alignment of svg icons

Abierto
#31,576 5 comentarios 9 reacciones 0 asignados Ver en GitHub
area: material/button P2
Lenguaje dominante
TypeScript
Estrellas
25k
Forks
6.8k
Merge medio
1 d 8 h
PR fusionados (30 d)
91

Descripción

### Is this a regression?

- [x] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

20.0.5

### Description

After update to angular/material 20.1.+

Material buttons with icons no longer align properly.

_________________________________________

**Before**

Image

**After**

Image

_________________________________________

**What causing an issue?**

After removing `min-height`, everything works as before.
My icon size is 24px, but with `min-height: fit-content`, the .mat-icon container gets stretched while the SVG icon remains the same size.

For example:
- `.mat-icon: 24px × 29px`
- `svg: 24px × 24px`

This causes vertical misalignment of icons compared to previous versions.

Image

I believe this PR is the cause of this issue.: https://github.com/angular/components/pull/30891
commit -> https://github.com/angular/components/pull/30891/commits/87b6962841454cfde8200b9c9de7ad73079416ae

_________________________________________

### Reproduction

StackBlitz link:
Steps to reproduce:
1.
2.

### Expected Behavior

The `.mat-icon` inside `.mat-mdc-button-base` should remain properly aligned and not stretch vertically.
The mat-icon container should match the size of the SVG icon `(24px × 24px)` when the icon size is set to `24px`.

### Actual Behavior

With `min-height: fit-content;` applied, the .mat-icon container stretches vertically `(e.g., 24px × 29px) `while the SVG icon stays 24px × 24px.
This causes misalignment and extra spacing around the icon compared to previous versions.

### Environment

- Angular: 20.1.2
- CDK/Material: 20.1.2
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): macOS

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Revisa los estilos de los botones de Angular Material alrededor de `.mat-mdc-button-base` y `.mat-icon`, y luego compara el comportamiento introducido por el commit 87b6962841454cfde8200b9c9de7ad73079416ae de PR 30891 con la versión 20.0.5. Reprodúcelo con un icono SVG de 24px en Angular/Material 20.1.2 y verifica que el contenedor siga siendo de 24px × 24px y que el icono esté alineado verticalmente.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, css, typescript
Área
frontend
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
42/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.