Skip to content

fix(ui): reset message textarea height after sending - #221

Merged
sanity merged 3 commits into
mainfrom
fix-textarea-reset
Apr 18, 2026
Merged

fix(ui): reset message textarea height after sending#221
sanity merged 3 commits into
mainfrom
fix-textarea-reset

Conversation

@sanity

@sanity sanity commented Apr 18, 2026

Copy link
Copy Markdown
Contributor

Problem

Typing a multi-line message auto-grows the textarea (height follows scrollHeight, capped at 168px), but after hitting Enter to send, the textarea stayed at its expanded height instead of shrinking back to a single line. The message was cleared, but the input bar took up 4+ lines of empty space until the user typed again.

Approach

The auto_resize() call inside send_message ran synchronously immediately after message_text.set(String::new()). Dioxus hasn't flushed the signal change to the DOM yet at that point, so scrollHeight still reflects the pre-send (expanded) content, and the resize computes the old height.

Fix: defer the resize via crate::util::defer() (our wrapper around setTimeout(0) that also pushes the Dioxus runtime + root scope) so it runs on the next tick, after Dioxus has propagated the cleared value to the textarea's DOM.

Also pulled the resize logic into a free function. It captures nothing from the component, and making it a plain fn avoids move-of-closure issues when passing it to defer.

Testing

Manually verified in a local browser against cargo make build-ui-example-no-sync:

  • Initial textarea height: 44px (one row)
  • After typing a 5-line message: 140px (expanded)
  • After hitting Enter to send: 44px (back to initial)

cargo fmt + cargo clippy -p river-ui --target wasm32-unknown-unknown --features no-sync clean for the touched file.

Only UI code changed — no delegate or contract WASM impact, no migration entry needed.

[AI-assisted - Claude]

sanity and others added 3 commits April 18, 2026 14:33
Typing a multi-line message auto-grows the textarea via scrollHeight,
but after hitting Enter to send, the textarea stayed expanded instead
of shrinking back to one line.

The `auto_resize()` call inside `send_message` ran synchronously right
after `message_text.set(String::new())`. Dioxus hasn't flushed the
signal change to the DOM yet at that point, so `scrollHeight` still
reflects the pre-send (expanded) content, and the resize computes the
old height. Defer the resize via `crate::util::defer()` so it runs on
the next tick after Dioxus has cleared the textarea's `value`.

Also pulled the resize logic into a free function — it captures nothing
from the component, and making it a plain `fn` avoids move-of-closure
issues when passing it to `defer`.

Verified in a local browser: 44px initial → 140px with 5-line message
→ 44px after send.

[AI-assisted - Claude]

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Covers #221. Verified the test fails against the pre-fix
code (height stays at 140px after Enter-to-send) and passes across all
5 Playwright projects (chromium, firefox, webkit, mobile-chrome,
mobile-safari) with the defer-based fix in place.

[AI-assisted - Claude]

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
constant_time_eq 0.4.3 was published 2026-04-18 and requires rustc
1.95.0, but rust-toolchain.toml pins rustc to 1.94.1 to keep WASM
hashes deterministic (see the comment in that file). Without a
committed Cargo.lock, every fresh CI build picked up 0.4.3 and failed
at dependency check with "requires rustc 1.95.0".

Pin constant_time_eq to 0.4.2 in both the build and ui-playwright-tests
jobs before running cargo make. Long-term fix is to either bump the
toolchain (requires delegate migration) or commit Cargo.lock; both are
out of scope for this PR.

[AI-assisted - Claude]

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sanity
sanity merged commit 3c81da1 into main Apr 18, 2026
5 checks passed
@sanity
sanity deleted the fix-textarea-reset branch April 18, 2026 20:00
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.

1 participant