I want the textarea to scroll to cursor once the row number has been changed.
Sometimes when I change the row number reducing it the cursor goes out of view
How do I make it so that the cursor stays in view?
startPos = ta.selectionStart;
const endPos = ta.selectionEnd;
newText = "";
ta.blur();
ta.focus();
ta.setRangeText(newText, startPos, endPos, 'end');
ta.rows = "6";
Context:
The textarea is originally 26 rows big, I resize it using javascript onfocus event to 6 rows. However, when the cursor is in a position that is somewhere over 6 rows when I resize it is not shown unless I manually scroll to it.