-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Closed
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/form-field
Description
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 the mat-label
tag is removed from a mat-form-field
a white gap remains visible.
<mat-form-field appearance="outline">
@if (hasLabel$ | async){
<mat-label>My input</mat-label>
}
<input matInput type="text" [(ngModel)]="name" />
</mat-form-field>
export class App {
hasLabel$ = new BehaviorSubject(true);
name = '';
ngOnInit() {
setTimeout(() => {
this.hasLabel$.next(false);
}, 3000);
}
}
Reproduction
Expected Behavior
If hasLabel$
has a default value of false
hasLabel$ = new BehaviorSubject(false);
and mat-label
is hidden from the start, it works as it should, but I would expect it to work as well if the label is removed later.
Actual Behavior
The blank space remains visible.
Environment
- Angular: 18
- CDK/Material: 18
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/form-field