Skip to content

bug(mat-form-field): updateOutlineGap does not recalculate when label is changed to be empty #23943

Closed
@ko-tori

Description

@ko-tori

Description

Some logic in updateOutlineGap skips recalculation when the label content is falsy. This prevents the outlineGap from updating when the label is cleared. It seems like the same logic also prevents the outline gap from updating when the label is removed altogether. In these cases, instead of just returning, the outline should be restored to default.

Reproduction

https://stackblitz.com/edit/angular-nmdjyj

Steps to reproduce:

  1. Have a form-field with appearance="outline" and a mat-label
  2. After loading and outline gap is calculated, set the contents of the mat-label to ""

Expected Behavior

Focusing the form-field should show no outline gap

Actual Behavior

Focusing the form-field should shows an outline gap

Environment

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

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/form-field

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions