@@ -198,26 +198,30 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
198
198
}
199
199
200
200
// Use a clone element because we have to override some styles.
201
- let textareaClone = this . _textareaElement . cloneNode ( false ) as HTMLTextAreaElement ;
201
+ const textareaClone = this . _textareaElement . cloneNode ( false ) as HTMLTextAreaElement ;
202
+ const cloneStyles = textareaClone . style ;
202
203
textareaClone . rows = 1 ;
203
204
204
205
// Use `position: absolute` so that this doesn't cause a browser layout and use
205
206
// `visibility: hidden` so that nothing is rendered. Clear any other styles that
206
207
// would affect the height.
207
- textareaClone . style . position = 'absolute' ;
208
- textareaClone . style . visibility = 'hidden' ;
209
- textareaClone . style . border = 'none' ;
210
- textareaClone . style . padding = '0' ;
211
- textareaClone . style . height = '' ;
212
- textareaClone . style . minHeight = '' ;
213
- textareaClone . style . maxHeight = '' ;
208
+ cloneStyles . position = 'absolute' ;
209
+ cloneStyles . visibility = 'hidden' ;
210
+ cloneStyles . border = 'none' ;
211
+ cloneStyles . padding = '0' ;
212
+ cloneStyles . height = '' ;
213
+ cloneStyles . minHeight = '' ;
214
+ cloneStyles . maxHeight = '' ;
215
+
216
+ // App styles might be messing with the height through the positioning properties.
217
+ cloneStyles . top = cloneStyles . bottom = cloneStyles . left = cloneStyles . right = 'auto' ;
214
218
215
219
// In Firefox it happens that textarea elements are always bigger than the specified amount
216
220
// of rows. This is because Firefox tries to add extra space for the horizontal scrollbar.
217
221
// As a workaround that removes the extra space for the scrollbar, we can just set overflow
218
222
// to hidden. This ensures that there is no invalid calculation of the line height.
219
223
// See Firefox bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=33654
220
- textareaClone . style . overflow = 'hidden' ;
224
+ cloneStyles . overflow = 'hidden' ;
221
225
222
226
this . _textareaElement . parentNode ! . appendChild ( textareaClone ) ;
223
227
this . _cachedLineHeight = textareaClone . clientHeight ;
0 commit comments