mirror of
https://github.com/immich-app/immich.git
synced 2025-12-26 01:11:47 +03:00
20 lines
477 B
TypeScript
20 lines
477 B
TypeScript
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 };
|
|
};
|