fix: fix autosize when not rendered at initialization

This commit is contained in:
Ruben Fiszel
2024-04-17 22:42:03 +02:00
parent ca3e2888a6
commit cdb01b0d01
+8 -1
View File
@@ -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 = () => {