From 68fa7ef6d3a0ad6b47e27f422ac7f208d51cc203 Mon Sep 17 00:00:00 2001 From: suedeapple Date: Tue, 29 Sep 2026 11:13:42 +0100 Subject: [PATCH] Fix auto-height textarea collapsing to 2px when shown uui-textarea measures its auto height when connected. If the property is hidden with display: none at that point it collapses to ~2px and never re-measures. Re-run autoUpdateHeight() on any auto-height textareas when a hidden property or group is shown again. Fixes #58 --- ConditionalDisplayers/Client/src/sharedLogic.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ConditionalDisplayers/Client/src/sharedLogic.ts b/ConditionalDisplayers/Client/src/sharedLogic.ts index 104f3bb..0db5489 100644 --- a/ConditionalDisplayers/Client/src/sharedLogic.ts +++ b/ConditionalDisplayers/Client/src/sharedLogic.ts @@ -31,7 +31,11 @@ export const toggleElements = (aliases: string, isShow: boolean, hostElement: HT : el) ?? el; if (isShow) { + const wasHidden = target.style.display === 'none'; target.style.removeProperty('display'); + if (wasHidden) { + refreshAutoHeightTextareas(target); + } } else { target.style.display = 'none'; } @@ -40,6 +44,18 @@ export const toggleElements = (aliases: string, isShow: boolean, hostElement: HT } } +/** + * uui-textarea measures its auto height when connected. If that happens while hidden (display: none) + * it collapses to ~2px and never recovers, so re-measure once the element is visible again. + */ +const refreshAutoHeightTextareas = (container: HTMLElement) => { + requestAnimationFrame(() => { + deepQuerySelectAll('uui-textarea[auto-height]', container, false).forEach((textarea) => { + (textarea as HTMLElement & { autoUpdateHeight?: () => void }).autoUpdateHeight?.(); + }); + }); +} + const elSelectors = (aliasList: string[]): string => { let cssSelector = "";