diff --git a/web/src/lib/actions/autogrow.ts b/web/src/lib/actions/autogrow.ts index 664039cb2a..0e6dec8e81 100644 --- a/web/src/lib/actions/autogrow.ts +++ b/web/src/lib/actions/autogrow.ts @@ -1,7 +1,19 @@ -export const autoGrowHeight = (textarea?: HTMLTextAreaElement, height = 'auto') => { - if (!textarea) { - return; - } - textarea.style.height = height; - textarea.style.height = `${textarea.scrollHeight}px`; +import { tick } from 'svelte'; +import type { Action } from 'svelte/action'; + +type Parameters = { + height?: string; + value: string; // added to enable reactivity +}; + +export const autoGrowHeight: Action = (textarea, { height = 'auto' }) => { + const update = () => { + void tick().then(() => { + textarea.style.height = height; + textarea.style.height = `${textarea.scrollHeight}px`; + }); + }; + + update(); + return { update }; }; diff --git a/web/src/lib/components/asset-viewer/activity-viewer.svelte b/web/src/lib/components/asset-viewer/activity-viewer.svelte index 34940aee56..ce0ca9ac56 100644 --- a/web/src/lib/components/asset-viewer/activity-viewer.svelte +++ b/web/src/lib/components/asset-viewer/activity-viewer.svelte @@ -77,7 +77,6 @@ onClose, }: Props = $props(); - let textArea: HTMLTextAreaElement | undefined = $state(); let innerHeight: number = $state(0); let activityHeight: number = $state(0); let chatHeight: number = $state(0); @@ -142,10 +141,6 @@ }); reactions.push(data); - if (textArea) { - textArea.style.height = '18px'; - } - message = ''; onAddComment(); // Re-render the activity feed @@ -306,11 +301,9 @@