From e0e494da49a331062c9a7f49a789f8f057f9db19 Mon Sep 17 00:00:00 2001 From: Sarah Richards <62299569+sarah-storm@users.noreply.github.com> Date: Thu, 10 Oct 2024 14:47:51 +0100 Subject: [PATCH] remove auto height setting (#268) * remove auto height setting * Update to cache scroll position --- packages/textarea/src/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/textarea/src/index.js b/packages/textarea/src/index.js index 927078de..04db0355 100644 --- a/packages/textarea/src/index.js +++ b/packages/textarea/src/index.js @@ -4,8 +4,10 @@ import { getSelection } from './lib/utils'; const isHidden = el => el.offsetParent === null; const update = ({ target }) => { - target.style.height = 'auto'; - target.style.height = `${target.scrollHeight}px`; + const scrollCache = window.scrollY; + target.style.height = 'auto'; + target.style.height = `${target.scrollHeight}px`; + window.scrollTo(0, scrollCache); }; const initObserver = el => { const observer = new MutationObserver(mutationsList => {