angular / angular/components

bug(form-field): label position doesn't take outline-width into consideration

Offen
#31,474 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
P2
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

### Is this a regression?

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

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

_No response_

### Description

When using form-field with the outline appearance, the vertical position of the label isn't taking into consideration the outline width.
which means that the thicker the outline is, the more the label is offset from the center.

Image

When using 2px outline, this is not really visible, unless you dynamically change the outline width from 1px to 2px when hovering the form-field, which is really annoying to experience 😅

![Image](https://github.com/user-attachments/assets/b11d34fb-603d-4ef1-87cf-82d6d023c219)

### Reproduction

https://stackblitz.com/edit/tk7fhpq7?file=src%2Fexample%2Fform-field.scss

### Expected Behavior

The label should remain vertically centered like the input value/placeholder is.

### Actual Behavior

The label isn't vertically centered like the input value/placeholder is.

### Environment

- Angular: 20.0.4
- CDK/Material: 20.0.4
- Browser(s): Chrome 137
- Operating System: macOS

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start with the linked StackBlitz reproduction and inspect src/example/form-field.scss to reproduce the outline-label offset with different outline widths. Trace the Angular Material form-field outline label positioning, then verify that the label remains vertically centered like the input value or placeholder across the reported widths.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
frontend
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
55/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.