Skip to content

input: Make rows set the height of a plain Textarea again - #3330

Merged
huacnlee merged 1 commit into
longbridge:mainfrom
Bombatomica64:fix/textarea-rows
Oct 1, 2026
Merged

huacnlee merged 1 commit into
longbridge:mainfrom
Bombatomica64:fix/textarea-rows

Conversation

@Bombatomica64

@Bombatomica64 Bombatomica64 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3325

Description

TextareaState::rows(n) had no effect on a plain (non-auto-grow) Textarea: it was always one line tall unless the app gave it an explicit height. The Textarea story compensates with .h(px(320.)) next to .rows(10).

Root cause: LayoutMode::update_auto_grow runs for every multi-line input (on layout changes and edits) and calls set_rows(wrapped_line_count). For PlainText and CodeEditor that overwrote the configured rows with the content's line count. A rows-based minimum height would then have grown the input to fit its whole content. Since #1191 the non-auto-grow branch in TextElement::request_layout has used a one-line minimum instead, and rows was effectively ignored.

This PR:

  • makes update_auto_grow a no-op outside auto-grow mode, so a configured rows survives layout and edits;
  • uses the same rows * line_height minimum height for every multi-line mode again (auto-grow keeps its max_rows cap);
  • fixes the stale rows doc comment ("default: 2" → 1).

Behaviour change to note: a default Textarea is unchanged (1 row), but a code editor's default rows: 2 now applies, so an editor in a container shorter than two lines grows to two lines. I found no test or story that depends on that. Happy to keep editors at one line if you prefer.

Screenshot

Screen recordings on Android (Redroid, dark theme) of opening a screen with a .rows(5) Textarea (4 lines of content) and a .rows(3) Textarea with inline tokens, Kit 0.7.0 with and without this diff.

Before

pr3330-before.mp4

After

pr3330-after.mp4

Before: both Textareas are one line tall and the rest is clipped. After: they are five and three rows tall.
Builds: demo-pr3330.

How to Test

  • New rows_set_the_minimum_height_of_a_plain_textarea in crates/kit/tests/input/textarea.rs renders rows(1), rows(2) and rows(5) Textareas in auto-height containers and checks that five rows add exactly four times what the second row adds. It fails on main.
  • Restoring the minimum height alone (without the update_auto_grow gate) breaks 6 existing tests: fixed-viewport navigation, page movement, decoration clipping, search reveal and touch-menu scrolling. That breakage exposed the root cause, and all six pass with this change.
  • cargo test -p gpui-kit --features test-support,component --tests: all pass (input: 161).
  • cargo test -p gpui-base --features test-support --lib: 1244 passed.
  • cargo test -p gpui-component --features test-support --lib: 578 passed.

Checklist

  • I have read the CONTRIBUTING document and followed the guidelines.
  • Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate.
  • Passed cargo run for story tests related to the changes. (Not run: no desktop session here; see How to Test.)
  • Tested macOS, Windows and Linux platforms performance (if the change is platform-specific) (not platform-specific)

Thanks for taking the time to review this.

🤖 Generated with Claude Code

update_auto_grow ran for every multi-line input and overwrote rows with
the content's wrapped line count, not only in auto grow mode. Since
longbridge#1191 a plain Textarea therefore got a one-line minimum height instead
of rows * line_height, and .rows(n) had no visible effect.

Only auto grow now tracks the content, so a configured rows value
survives layout and edits, and every multi-line input is again at least
rows tall. The default row count of a Textarea stays 1; a code editor's
default of 2 rows now applies as its minimum height.

Closes longbridge#3325

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings September 30, 2026 07:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Bombatomica64

Bombatomica64 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

I've added before/after screen recordings to the Screenshot section (Android, dark theme, Kit 0.7.0 with and without this diff).

Before

pr3330-before.mp4

After

pr3330-after.mp4

The first Textarea is .rows(5) and the inline-tokens one is .rows(3).

@huacnlee
huacnlee merged commit eb0cc13 into longbridge:main Oct 1, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Textarea: rows(n) does not set the height of a plain multi-line Textarea

3 participants