@@ -114,7 +114,7 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
114
114
}
115
115
116
116
/** Cached height of a textarea with a single row. */
117
- private _cachedLineHeight : number ;
117
+ private _cachedLineHeight ? : number ;
118
118
/** Cached height of a textarea with only the placeholder. */
119
119
private _cachedPlaceholderHeight ?: number ;
120
120
@@ -165,7 +165,12 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
165
165
this . _renderer . listen ( this . _textareaElement , 'focus' , this . _handleFocusEvent ) ,
166
166
this . _renderer . listen ( this . _textareaElement , 'blur' , this . _handleFocusEvent ) ,
167
167
] ;
168
- this . _resizeEvents . pipe ( auditTime ( 16 ) ) . subscribe ( ( ) => this . resizeToFitContent ( true ) ) ;
168
+ this . _resizeEvents . pipe ( auditTime ( 16 ) ) . subscribe ( ( ) => {
169
+ // Clear the cached heights since the styles can change
170
+ // when the window is resized (e.g. by media queries).
171
+ this . _cachedLineHeight = this . _cachedPlaceholderHeight = undefined ;
172
+ this . resizeToFitContent ( true ) ;
173
+ } ) ;
169
174
} ) ;
170
175
171
176
this . _isViewInited = true ;
@@ -263,6 +268,8 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
263
268
return ;
264
269
}
265
270
271
+ console . log ( 'measuring placeholder' ) ;
272
+
266
273
const value = this . _textareaElement . value ;
267
274
268
275
this . _textareaElement . value = this . _textareaElement . placeholder ;
0 commit comments