Skip to content

Commit a495d3a

Browse files
committed
fix(user-input): document auto-focus RAF ordering relative to draft restore
1 parent fa29e76 commit a495d3a

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/home/components/user-input

apps/sim/app/workspace/[workspaceId]/home/components/user-input/user-input.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,9 @@ export const UserInput = forwardRef<UserInputHandle, UserInputProps>(function Us
536536
wasSendingRef.current = isSending
537537
}, [isSending, textareaRef])
538538

539+
// Auto-focus on mount. The RAF runs after all synchronous mount effects, so if
540+
// the draft-restore effect already focused the textarea the isEditingElsewhere
541+
// guard below will be true and we skip the re-focus, preserving cursor position.
539542
useEffect(() => {
540543
const raf = window.requestAnimationFrame(() => {
541544
const active = document.activeElement

0 commit comments

Comments
 (0)