@@ -198,26 +198,30 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
198198 }
199199
200200 // 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 ;
202203 textareaClone . rows = 1 ;
203204
204205 // Use `position: absolute` so that this doesn't cause a browser layout and use
205206 // `visibility: hidden` so that nothing is rendered. Clear any other styles that
206207 // 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' ;
214218
215219 // In Firefox it happens that textarea elements are always bigger than the specified amount
216220 // of rows. This is because Firefox tries to add extra space for the horizontal scrollbar.
217221 // As a workaround that removes the extra space for the scrollbar, we can just set overflow
218222 // to hidden. This ensures that there is no invalid calculation of the line height.
219223 // See Firefox bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=33654
220- textareaClone . style . overflow = 'hidden' ;
224+ cloneStyles . overflow = 'hidden' ;
221225
222226 this . _textareaElement . parentNode ! . appendChild ( textareaClone ) ;
223227 this . _cachedLineHeight = textareaClone . clientHeight ;
0 commit comments