Skip to content

fix(desktop): resolve composer cursor drift on multi-line input#153

Merged
wesbillman merged 1 commit intomainfrom
fix/composer-cursor-drift
Mar 21, 2026
Merged

fix(desktop): resolve composer cursor drift on multi-line input#153
wesbillman merged 1 commit intomainfrom
fix/composer-cursor-drift

Conversation

@wesbillman
Copy link
Collaborator

Problem

When typing multi-line text in the message composer, the cursor drifts upward from the actual text position. By the 3rd line, the cursor is ~12px above where the text appears, making it difficult to see what you're typing.

Root Cause

The base Textarea component (shared/ui/textarea.tsx) includes md:text-sm in its default classes. At the md breakpoint, md:text-sm sets both font-size: 0.875rem and line-height: 1.25rem (20px). The composer overrides with leading-6 (24px line-height), but the responsive md:text-sm has higher CSS specificity and wins at desktop widths.

Meanwhile, the ComposerMentionOverlay (a plain <div>) uses text-sm leading-6 without any responsive override, so it keeps line-height: 24px at all breakpoints.

This mismatch — textarea at 20px vs overlay at 24px — causes the caret to drift 4px per line away from the overlay's visible text.

Fix

Add md:leading-6 to the Textarea className in MessageComposer.tsx so the line-height override wins at the md breakpoint too. This ensures both the textarea and overlay use a consistent 24px line-height at all breakpoints.

Follow-up (separate PR)

  • Extract shared text classes into a constant for explicit textarea ↔ overlay coupling
  • Replace DOM-read lineHeightRef with a constant (24px at all breakpoints now)
  • Add defensive md:leading-6 to the overlay for symmetry

The base Textarea component's md:text-sm responsive class was overriding
the composer's leading-6 line-height at md+ breakpoints, causing a 4px
per-line drift between the textarea caret and the mention overlay text.
Adding md:leading-6 ensures consistent 24px line-height at all breakpoints.
@wesbillman wesbillman merged commit 325def6 into main Mar 21, 2026
8 checks passed
@wesbillman wesbillman deleted the fix/composer-cursor-drift branch March 21, 2026 18:08
tlongwell-block added a commit that referenced this pull request Mar 22, 2026
* origin/main:
  feat: sprout-cli — agent-first CLI with full MCP parity (48 commands) (#158)
  fix(desktop): resolve composer cursor drift on multi-line input (#153)

# Conflicts:
#	crates/sprout-relay/src/router.rs
tlongwell-block added a commit that referenced this pull request Mar 22, 2026
* origin/main:
  feat: sprout-cli — agent-first CLI with full MCP parity (48 commands) (#158)
  fix(desktop): resolve composer cursor drift on multi-line input (#153)
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