From fdc59b1ec7ea0bdba96c30f16a25174abbe4548f Mon Sep 17 00:00:00 2001 From: Faton Ramadani Date: Wed, 17 Apr 2024 16:46:44 +0200 Subject: [PATCH] fix(frontend): Fix autosize within hidden components --- frontend/src/lib/autosize.ts | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/frontend/src/lib/autosize.ts b/frontend/src/lib/autosize.ts index 4957c939b3..b93434938e 100644 --- a/frontend/src/lib/autosize.ts +++ b/frontend/src/lib/autosize.ts @@ -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 {