I have a textarea in which I have a button as well in the bottom right corner.
Everything looks great unless I add more words and it overlaps the button.
What I want to do is as soon as someone reaches the last line, the size of the textarea increases automatically. I have found one solution in codepen - https://codepen.io/anon/pen/gLdRXE But I am not sure how to implement the same using React. Also, I am using textarea and not input tag.
textarea{
width:100%;
min-height:80px;
max-height:200px;
overflow:auto;
resize:vertical;
}
var textarea = document.querySelector('textarea');
textarea.addEventListener('keydown', autosize);
function autosize(){
var el = this;
setTimeout(function(){
el.style.cssText = 'height:auto; padding:0';
el.style.cssText = 'height:' + el.scrollHeight + 'px';
},0);
}
Many thanks