From cdb01b0d01865dc0910ee42464869d3f69e12c1b Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Wed, 17 Apr 2024 22:42:03 +0200 Subject: [PATCH] fix: fix autosize when not rendered at initialization --- frontend/src/lib/autosize.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/lib/autosize.ts b/frontend/src/lib/autosize.ts index cdf560bd80..6a3a9b4107 100644 --- a/frontend/src/lib/autosize.ts +++ b/frontend/src/lib/autosize.ts @@ -17,6 +17,13 @@ export const action = (node) => { const setInitialHeight = () => { let height = 0 + const style = window.getComputedStyle(node) + const visible = style?.getPropertyValue('visibility') === 'hidden' + + if (visible === false) { + return + } + if (node.value) { height = node.scrollHeight } else { @@ -37,7 +44,7 @@ export const action = (node) => { const setHeight = () => { node.style.height = '0px' - node.style.height = Math.max(node.scrollHeight, 40) + 5 + 'px' + node.style.height = Math.max(node.scrollHeight ?? 0, 40) + 5 + 'px' } const addStyles = () => {