//textarea_change -- resizes textarea as you type
function textarea_change() {
// https://stackoverflow.com/questions/7745741/auto-expanding-textarea
for (const textarea of document.getElementsByTagName("textarea")) {
textarea.onfocus = ""
textarea.onblur = ""
textarea.setAttribute("charcount", textarea.value.length);
textarea.oninput = function() {
var textlen = textarea.value.length,
charcount = textarea.getAttribute("charcount"),
difference = charcount - textlen,
shrink = 0.2,
minimum = 60;
if (textlen == 0) {
textarea.style.height = "";
}
if (textlen < charcount) {
textarea.style.height = Math.max(minimum, parseFloat(textarea.style.height).toFixed(2) - (shrink * difference)) + "px";
textarea.setAttribute("charcount", textlen);
return;
}
//textarea.style.height = ""
//textarea.style.height = Math.max(80 , (15 * textarea.value.split(/\r\n|\r|\n/).length)) + "px";
textarea.style.height = Math.max(minimum, textarea.scrollHeight) + "px";
textarea.setAttribute("charcount", textarea.value.length);
//window.scrollTo(0, document.body.scrollHeight)
}
if (autofill_sage) textarea_autofill_sage(textarea)
}
}

Edit Report
Pub: 21 Sep 2022 20:32 UTC
Views: 89