cburschka / cadence

A strophe.js-powered XMPP web client for chatrooms.
6 stars 2 forks source link

Autogrow textarea #455

Open cburschka opened 7 years ago

cburschka commented 7 years ago

To expand on #420, the field could theoretically grow (up to a set height) when text is entered.

As it is right now, the textarea is easily altered by simply setting the rows property to any integer value.

By setting the container's max-height, we can put a hard limit on how much the textarea can grow.

The area's contents' line count can be calculated by dividing the area's scrollHeight property (minus its vertical padding) by the lineHeight CSS property (14px by default).

Problem: The scroll height is at least the element's actual height, so a naive implementation will allow the text area to grow as text is entered, but never shrink.