Skip to content

Commit 0cd8867

Browse files
committed
fixup! fix(cdk/text-field): autosize text areas using the placeholder
1 parent cbe9be6 commit 0cd8867

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/cdk/text-field/autosize.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
108108
/** Class that should be applied to the textarea while it's being measured. */
109109
private _measuringClass: string;
110110

111+
private _isViewInited = false;
112+
111113
constructor(private _elementRef: ElementRef<HTMLElement>,
112114
private _platform: Platform,
113115
private _ngZone: NgZone,
@@ -155,6 +157,9 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
155157
.pipe(auditTime(16), takeUntil(this._destroyed))
156158
.subscribe(() => this.resizeToFitContent(true));
157159
});
160+
161+
this._isViewInited = true;
162+
this._cacheTextareaPlaceholderHeight();
158163
}
159164
}
160165

@@ -219,7 +224,11 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
219224
}
220225

221226
private _cacheTextareaPlaceholderHeight(): void {
222-
if (this._cachedPlaceholderHeight) {
227+
if (!this._isViewInited || this._cachedPlaceholderHeight != undefined) {
228+
return;
229+
}
230+
if (!this.placeholder) {
231+
this._cachedPlaceholderHeight = 0;
223232
return;
224233
}
225234

0 commit comments

Comments
 (0)