fix(web): update description height when navigating between assets (#14145)

This commit is contained in:
Michel Heusschen
2024-11-14 16:59:30 +01:00
committed by GitHub
parent d1085e8a02
commit 1fa0122eda
3 changed files with 22 additions and 22 deletions
+18 -6
View File
@@ -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<HTMLTextAreaElement, Parameters> = (textarea, { height = 'auto' }) => {
const update = () => {
void tick().then(() => {
textarea.style.height = height;
textarea.style.height = `${textarea.scrollHeight}px`;
});
};
update();
return { update };
};