Measuring scrollHeight on the live textarea with an explicit height set can only grow — it can never report a shorter content height. The old `height: auto` toggle flickered across browsers. Use a hidden off-DOM textarea that mirrors the composer's text-metric styles and width, and read its scrollHeight on value/resize changes. Gated by Metro file extension (.web / .native) so it's trivial to rip out later.
14 lines
322 B
TypeScript
14 lines
322 B
TypeScript
import type { RefObject } from "react";
|
|
|
|
interface Args {
|
|
value: string;
|
|
textareaRef: RefObject<unknown>;
|
|
minHeight: number;
|
|
maxHeight: number;
|
|
onHeight: (height: number) => void;
|
|
}
|
|
|
|
export function useComposerHeightMirror(_args: Args): void {
|
|
// No-op on native: onContentSizeChange drives height natively.
|
|
}
|