diff --git a/packages/textarea/package.json b/packages/textarea/package.json index bd7c8bcb..b51d7858 100644 --- a/packages/textarea/package.json +++ b/packages/textarea/package.json @@ -1,6 +1,6 @@ { "name": "@stormid/textarea", - "version": "1.0.0-alpha.7", + "version": "1.0.0-alpha.8", "description": "Auto-resizing textarea", "author": "stormid", "license": "MIT", 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 => {