Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ion-textarea autoGrow scroll to top on input

In my Ionic 5 app when an ion-textarea with autoGrow="true" becomes long in height, it always scrolls to top on input, when the user's input exceeds screen height. This exact issue was reported here and the fix is said to be merged here.

My Ionic version is 6.16.1 and I am facing this issue. The issue can be checked here

like image 337
Tapas Mukherjee Avatar asked Jan 22 '26 17:01

Tapas Mukherjee


1 Answers

by checking the links you shared, there is this answer that seems to work on your stackblitz : https://github.com/ionic-team/ionic-framework/pull/19776#issuecomment-549735550

In your html :

<ion-textarea auto-grow="true" (ionInput)="onTextInput($event)"> </ion-textarea>

In your .ts file :

onTextInput(event) { event.target.getInputElement().then((textArea: HTMLTextAreaElement) => { console.log(textArea.textLength + " : " + textArea.value); textArea.scroll({top: textArea.scrollHeight}); }); }
like image 54
uKioops Avatar answered Jan 25 '26 05:01

uKioops



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!