fix: autogrow textarea bugs during animation (#24481)

This commit is contained in:
Min Idzelis
2025-12-24 07:21:08 -05:00
committed by GitHub
parent e63e8e2517
commit 83f8065f10
6 changed files with 52 additions and 145 deletions
-19
View File
@@ -1,19 +0,0 @@
import { tick } from 'svelte';
import type { Action } from 'svelte/action';
type Parameters = {
height?: string;
value: string; // added to enable reactivity
};
export const autoGrowHeight: Action<HTMLTextAreaElement, Parameters> = (textarea, { height = 'auto' }) => {
const update = () => {
void tick().then(() => {
textarea.style.height = height;
textarea.style.height = `${textarea.scrollHeight}px`;
});
};
update();
return { update };
};