diff --git a/core/src/components/textarea/textarea.tsx b/core/src/components/textarea/textarea.tsx index 8c43d37b75..68030b1bd3 100644 --- a/core/src/components/textarea/textarea.tsx +++ b/core/src/components/textarea/textarea.tsx @@ -21,6 +21,7 @@ export class Textarea implements ComponentInterface { private nativeInput?: HTMLTextAreaElement; private inputId = `ion-input-${textareaIds++}`; private didBlurAfterEdit = false; + private textareaWrapper?: HTMLElement; @Element() el!: HTMLElement; @@ -191,13 +192,15 @@ export class Textarea implements ComponentInterface { this.runAutoGrow(); } - // TODO: performance hit, this cause layout thrashing private runAutoGrow() { const nativeInput = this.nativeInput; if (nativeInput && this.autoGrow) { readTask(() => { - nativeInput.style.height = 'inherit'; + nativeInput.style.height = 'auto'; nativeInput.style.height = nativeInput.scrollHeight + 'px'; + if (this.textareaWrapper) { + this.textareaWrapper.style.height = nativeInput.scrollHeight + 'px'; + } }); } } @@ -310,29 +313,34 @@ export class Textarea implements ComponentInterface { [mode]: true, }} > - + + ); }