From 4d2d504799767af870da319b7bbf7d4510ad077e Mon Sep 17 00:00:00 2001 From: "Robert W. Pearce" Date: Fri, 11 Mar 2022 23:26:19 -0500 Subject: [PATCH] Fix: textarea larger than window being jumpy at the bottom --- source/index.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/index.tsx b/source/index.tsx index 09927ee..f7b464e 100644 --- a/source/index.tsx +++ b/source/index.tsx @@ -71,6 +71,15 @@ export const resize: Resize = (rows, el) => { el.style.height = '0' el.style.overflowY = overflowY el.style.height = `${getHeight(rows, el)}px` + + if (document.activeElement === el) { + if ( + el.getBoundingClientRect().bottom > window.innerHeight && + el.selectionStart === el.value.length + ) { + window.scrollTo(el.scrollLeft, el.scrollTop + el.scrollHeight) + } + } } }