input: Make rows set the height of a plain Textarea again - #3330
Merged
Merged
Conversation
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>
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.mp4After pr3330-after.mp4The first Textarea is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_growruns for every multi-line input (on layout changes and edits) and callsset_rows(wrapped_line_count). ForPlainTextandCodeEditorthat overwrote the configuredrowswith 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 inTextElement::request_layouthas used a one-line minimum instead, androwswas effectively ignored.This PR:
update_auto_growa no-op outside auto-grow mode, so a configuredrowssurvives layout and edits;rows * line_heightminimum height for every multi-line mode again (auto-grow keeps itsmax_rowscap);rowsdoc comment ("default: 2" → 1).Behaviour change to note: a default Textarea is unchanged (1 row), but a code editor's default
rows: 2now 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
rows_set_the_minimum_height_of_a_plain_textareaincrates/kit/tests/input/textarea.rsrendersrows(1),rows(2)androws(5)Textareas in auto-height containers and checks that five rows add exactly four times what the second row adds. It fails onmain.update_auto_growgate) 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
cargo runfor story tests related to the changes. (Not run: no desktop session here; see How to Test.)Thanks for taking the time to review this.
🤖 Generated with Claude Code