You would think it would be easy to set a TextArea’s height to its contentHeight. Well, it is easy once you dig, and dig and dig for properties. Why there isn’t a property setHeightToContentHeight is beyond me. But there’s also not a property fixBugsOnApplicationInit which I think would be pretty darn handy.

This seems to be working for me:

     updateComplete="{ ta.height = ta.scroller.viewport.contentHeight + 2 }"; />

“Why is there the +2 at the end?”, you ask.

“I didn’t build the frakking thing!”, I reply.

Really, I have no clue why I have to tack on 2 to the height but if I don’t then sometimes I get the dreaded vertical scrollBar. So, I add 2. Call me crazy.

Just add text to the text input TextArea and it will be copied to the text output field. The height of the text output TextArea will grow as the number of lines of text increase.

view source

You might want to set the verticalScrollPolicy="off" of the TextArea. Otherwise the scrollBar will blink in and out when content is added. I left it on for the example so that you could see the effect.

What do you think?