We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 61273ac commit 923a7d7Copy full SHA for 923a7d7
staged/src/lib/NewSessionModal.svelte
@@ -45,13 +45,15 @@
45
}
46
});
47
48
- // Focus textarea on mount
+ // Focus textarea on mount (one-time)
49
$effect(() => {
50
if (textareaEl) {
51
- textareaEl.focus();
52
- if (prompt) {
53
- textareaEl.selectionStart = textareaEl.selectionEnd = prompt.length;
54
- }
+ const el = textareaEl;
+ // Read length from the DOM element to avoid tracking `prompt` reactively,
+ // which would re-run this effect on every keystroke and force the cursor
+ // to the end of the buffer.
55
+ el.focus();
56
+ el.selectionStart = el.selectionEnd = el.value.length;
57
58
59
0 commit comments