mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-09 16:05:42 +00:00
fix(frontend): Fix autosize within hidden components
This commit is contained in:
@@ -14,30 +14,16 @@ export const action = (node) => {
|
||||
node.dispatchEvent(update)
|
||||
}
|
||||
|
||||
const getParents = (element: Node): HTMLElement[] => {
|
||||
const parents: HTMLElement[] = []
|
||||
while (element.parentNode && element.parentNode.nodeName.toLowerCase() !== 'body') {
|
||||
element = element.parentNode as HTMLElement
|
||||
parents.push(element as HTMLElement)
|
||||
}
|
||||
return parents
|
||||
}
|
||||
|
||||
const hasInvisibleParent = (): boolean => {
|
||||
return getParents(node).some(
|
||||
(parent) => parent.classList.contains('hidden') || parent.style.display === 'none'
|
||||
)
|
||||
}
|
||||
|
||||
const setInitialHeight = () => {
|
||||
if (!hasInvisibleParent()) {
|
||||
adjustHeight()
|
||||
}
|
||||
}
|
||||
|
||||
const adjustHeight = () => {
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user