From 2d94f229c34150b4e8366ce6ee550ced3984605f Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sun, 10 Sep 2023 15:29:25 +0800 Subject: [PATCH] Fix weird textarea height on first render --- src/components/compose.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/compose.jsx b/src/components/compose.jsx index a020b97c..8b552321 100644 --- a/src/components/compose.jsx +++ b/src/components/compose.jsx @@ -1370,8 +1370,12 @@ const Textarea = forwardRef((props, ref) => { onInput={(e) => { const { scrollHeight, offsetHeight, clientHeight, value } = e.target; setText(value); - const offset = offsetHeight - clientHeight; - e.target.style.height = value ? scrollHeight + offset + 'px' : null; + if (offsetHeight < window.innerHeight) { + // NOTE: This check is needed because the offsetHeight return 50000 (really large number) on first render + // No idea why it does that, will re-investigate in far future + const offset = offsetHeight - clientHeight; + e.target.style.height = value ? scrollHeight + offset + 'px' : null; + } props.onInput?.(e); }} style={{