Skip to content

Commit e985173

Browse files
tomivirkkiclaude
andauthored
test: improve test coverage for text area height update logic (#11698)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3c0e1b1 commit e985173

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

packages/text-area/test/text-area.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,31 @@ describe('text-area', () => {
155155
expect(inputField.scrollTop).to.equal(200);
156156
});
157157

158+
it('should maintain scroll top on value shrink', async () => {
159+
textArea.style.maxHeight = '100px';
160+
const value = Array(400).join('400');
161+
setInputValue(textArea, value);
162+
await nextUpdate(textArea);
163+
164+
inputField.scrollTop = 50;
165+
setInputValue(textArea, value.slice(0, -1));
166+
await nextUpdate(textArea);
167+
168+
expect(inputField.scrollTop).to.equal(50);
169+
});
170+
171+
it('should match input height to its scroll height when input-field scrolls', async () => {
172+
textArea.style.width = '120px';
173+
textArea.style.maxHeight = '60px';
174+
textArea.value = Array(400).join('400');
175+
await nextUpdate(textArea);
176+
177+
setInputValue(textArea, textArea.value.slice(0, -1));
178+
await nextUpdate(textArea);
179+
180+
expect(parseFloat(native.style.height)).to.equal(native.scrollHeight);
181+
});
182+
158183
it('should decrease height automatically', async () => {
159184
textArea.value = Array(400).join('400');
160185
await nextUpdate(textArea);

0 commit comments

Comments
 (0)