jackmoore/autosize

Update not works when transition set to textarea

Closed this issue · 1 comments

Hello everyone! I'm using autosize with svelte and it works fine, but height doesn't update if I set transition to textarea and trying to delete text in textarea. I will be grateful for the help

Hi @andyBobro, unfortunately this in incompatible with the approach that autosize is using (it changes the textarea height and measures the scroll overflow, then changes the height to the desired height), as it requires instantaneous changes to the textarea element's measurements.

An alternative would be to mirror content into some off-screen textarea element and use that textarea as a basis for measurements, but there are other issues related to that approach. It's difficult to guarantee those two textarea elements are exactly the same size.

If I had this as a requirement, I would probably replace the textarea element with a content-editable div, as auto-height and CSS transition would be supported by default, and use JS to mirror it a textarea for form submission.