Skip to content

bug(mat-form-field): When matTextPrefix is applied, float-above transform applied to label element instead of class #28212

Open
@bmayen

Description

@bmayen

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

Not sure if this is a regression or not

Description

The floating label transform is normally applied via the label .mdc-floating-label--float-above class. However, when matTextPrefix is used on the mat-form-field, the transform is instead applied to the label element itself via inline style attribute. This makes attaching custom styles to the floated label inconsistent since the inline style has higher specificity than .mdc-floating-label--float-above class.

Reproduction

Apply matTextPrefix to an outline mat-form-field with a mat-label. Observe how transform styling is applied inline to the label.

https://components-issue-da4zuo.stackblitz.io/

Expected Behavior

I would expect transform styling to be applied consistently via .mdc-floating-label--float-above class.

Actual Behavior

Transform styling is applied via .mdc-floating-label--float-above class when matTextPrefix is not present, but applied via inline styling on the label element when matTextPrefix is present.

Environment

  • Angular: 16.x
  • CDK/Material: 16.x
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/form-fieldneeds: clarificationThe issue does not contain enough information for the team to determine if it is a real bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions