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 @@
import { describe, expect, test } from 'bun:test';
import { QUESTION_CUSTOM_TEXTAREA_MIN_HEIGHT, getQuestionCustomTextareaHeight } from '../questionTextareaSizing';
describe('getQuestionCustomTextareaHeight', () => {
test('exports the initial textarea height', () => {
expect(QUESTION_CUSTOM_TEXTAREA_MIN_HEIGHT).toBe(40);
});
test('returns null when the textarea is already at the target height', () => {
expect(getQuestionCustomTextareaHeight({ scrollHeight: 60, currentHeight: 60 })).toBeNull();
});
test('clamps textarea height between two and ten lines', () => {
expect(getQuestionCustomTextareaHeight({ scrollHeight: 10, currentHeight: 0 })).toBe(40);
expect(getQuestionCustomTextareaHeight({ scrollHeight: 120, currentHeight: 0 })).toBe(120);
expect(getQuestionCustomTextareaHeight({ scrollHeight: 260, currentHeight: 0 })).toBe(200);
});
});