fix: stabilize question custom textarea resizing (#1614)

* fix: stabilize question custom textarea resizing

* fix: preserve custom question answer state

---------

Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
HearingSmile
2026-06-13 00:28:42 +03:00
committed by GitHub
co-authored by Bohdan Triapitsyn
parent 8fbaa5df9c
commit 3bbd42587e
3 changed files with 123 additions and 32 deletions
@@ -0,0 +1,18 @@
const QUESTION_TEXTAREA_LINE_HEIGHT = 20;
const QUESTION_TEXTAREA_MIN_LINES = 2;
const QUESTION_TEXTAREA_MAX_LINES = 10;
export const QUESTION_CUSTOM_TEXTAREA_MIN_HEIGHT = QUESTION_TEXTAREA_LINE_HEIGHT * QUESTION_TEXTAREA_MIN_LINES;
export function getQuestionCustomTextareaHeight({
scrollHeight,
currentHeight,
}: {
scrollHeight: number;
currentHeight: number | null | undefined;
}): number | null {
const maxHeight = QUESTION_TEXTAREA_LINE_HEIGHT * QUESTION_TEXTAREA_MAX_LINES;
const nextHeight = Math.min(Math.max(scrollHeight, QUESTION_CUSTOM_TEXTAREA_MIN_HEIGHT), maxHeight);
return currentHeight === nextHeight ? null : nextHeight;
}