Measure GlFormTextarea auto-height on a hidden clone

What does this MR do?

GlFormTextarea's auto-height measurement makes a scrolled-to-the-end container jump up when the user types. computeHeight sets the live textarea to height: auto to read scrollHeight, which in max-rows mode collapses it to two rows for one forced layout. Any ancestor scroll container briefly grows, so the browser clamps its scrollTop, and restoring the height never undoes the clamp. In GitLab's Duo Agentic Chat this pushes the conversation up by (composer height − 2 rows) on the first keystroke: gitlab-org/gitlab#636490 (closed).

  • computeHeight measures an out-of-flow, hidden clone (same width and value) instead of the live textarea, so the page layout never changes.
  • The height calculation after the measurement is unchanged.
  • Adds a spec that the live textarea is never measured and no clone is left behind.
Verification in a GDK (Chromium)

A requestAnimationFrame recorder sampled the Duo Chat scroll container while typing five characters into a 9-line composer, starting at the bottom of a long conversation.

Before After
Chat scrollTop 1008, then 928 stays at 1008
Textarea height during measurement collapses to 80px stays at 160px

Auto-height still works: 1 line is 80px, 5 lines is 96px, 12 lines is 208px, 40 lines caps at 336px (20 rows), long wrapped text caps correctly, and clearing shrinks it back to 80px. Only one <textarea> is ever in the document.

Screenshots or screen recordings

Duo Agentic Chat in a GDK: the conversation is scrolled to the bottom and the composer holds about 9 lines. Then kikik is typed.

Before After

Integrations

No API change. The fix reaches GitLab through the normal @gitlab/ui version bump.

Edited by Nick Leonard

Merge request reports

Loading
Loading