[SOLVED] Ion-textarea resize height dynamically

I’ve found another solution how to handle the resizeing of a textarea, maybe it can help someone. I’ve wrote this, because I need it just once and and not multiple times across the app. If You need the resizeing across Your app, You could store the adjustTextarea(event) a helper class / provider or something like that.

<ion-textarea type="text" (input)="adjustTextarea($event);"></ion-textarea>
/**
 * function to adjust the height of the message textarea
 * @param {any} event - the event, which is provided by the textarea input
 * @return {void} 
 */
protected adjustTextarea(event: any): void {
	let textarea: any		= event.target;
	textarea.style.overflow = 'hidden';
	textarea.style.height 	= 'auto';
	textarea.style.height 	= textarea.scrollHeight + 'px';
	return;
}

Cheers
Unkn0wn0x

10 Likes