Skip to content

Commit 8fd3572

Browse files
crisbetojelbourn
authored andcommitted
fix(form-field): don't set up mutation observer on non-outline appearances (#12976)
Currently we use a `MutationObserver` to update the label gap when the label content changes. This is unnecessary on any appearance aside from `outline`.
1 parent 4102928 commit 8fd3572

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

src/cdk/observers/observe-content.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,7 @@ export class CdkObserveContent implements AfterContentInit, OnDestroy {
145145
get disabled() { return this._disabled; }
146146
set disabled(value: any) {
147147
this._disabled = coerceBooleanProperty(value);
148-
if (this._disabled) {
149-
this._unsubscribe();
150-
} else {
151-
this._subscribe();
152-
}
148+
this._disabled ? this._unsubscribe() : this._subscribe();
153149
}
154150
private _disabled = false;
155151

src/lib/form-field/form-field.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
read if it comes before the control in the DOM. -->
2929
<label class="mat-form-field-label"
3030
(cdkObserveContent)="updateOutlineGap()"
31+
[cdkObserveContentDisabled]="appearance != 'outline'"
3132
[id]="_labelId"
3233
[attr.for]="_control.id"
3334
[attr.aria-owns]="_control.id"

0 commit comments

Comments
 (0)