Skip to content

fix: prevent cursor jumping to end of textarea in NewSessionModal#17

Merged
baxen merged 1 commit intomainfrom
baxen/prompt-text-bug
Feb 10, 2026
Merged

fix: prevent cursor jumping to end of textarea in NewSessionModal#17
baxen merged 1 commit intomainfrom
baxen/prompt-text-bug

Conversation

@baxen
Copy link
Copy Markdown
Collaborator

@baxen baxen commented Feb 10, 2026

Problem

When typing in the textarea of the NewSessionModal, the cursor would jump to the end of the text on every keystroke. This made editing text in the middle of the prompt impossible.

Cause

The $effect that focused the textarea on mount was reading prompt reactively, causing it to re-run on every keystroke. Each re-run would set selectionStart and selectionEnd to prompt.length, forcing the cursor to the end.

Fix

Read the length from the DOM element's .value property instead of the reactive prompt variable. This avoids tracking prompt as a dependency, so the effect only runs once on mount (when textareaEl is first set) and correctly places the cursor at the end of any pre-filled text without interfering with subsequent edits.

The focus effect was reading the reactive prompt variable to set the
cursor position. In Svelte 5, this caused the effect to re-run on
every keystroke, resetting selectionStart/selectionEnd to prompt.length
and forcing the cursor to the end of the buffer.

Fix by reading el.value.length from the DOM element instead, which is
not a reactive dependency, keeping this as a one-time mount behavior.
@baxen baxen requested a review from wesbillman as a code owner February 10, 2026 04:56
@baxen baxen merged commit 923a7d7 into main Feb 10, 2026
1 of 2 checks passed
@baxen baxen deleted the baxen/prompt-text-bug branch February 10, 2026 05:02
loganj added a commit that referenced this pull request Feb 26, 2026
Add bulk actions to multi-file selection bar
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