Skip to content

fix: focus textarea instead of terminal when creating new chat#182

Open
erenbertr wants to merge 1 commit into21st-dev:mainfrom
erenbertr:fix/new-chat-focus-with-terminal-open
Open

fix: focus textarea instead of terminal when creating new chat#182
erenbertr wants to merge 1 commit into21st-dev:mainfrom
erenbertr:fix/new-chat-focus-with-terminal-open

Conversation

@erenbertr
Copy link

When the terminal panel is open and the user clicks "New Chat", focus was staying on the xterm textarea instead of moving to the chat editor. The requestAnimationFrame callback fired too early — before the browser's focus management settled after React's DOM updates. Switch to setTimeout(100ms) to ensure the editor focus call happens after all pending focus transitions complete. This matches the pattern already used in new-chat-form.tsx.

Also adds proper cleanup (clearTimeout) to the useEffect.

When the terminal panel is open and the user clicks "New Chat",
focus was staying on the xterm textarea instead of moving to the
chat editor. The requestAnimationFrame callback fired too early —
before the browser's focus management settled after React's DOM
updates. Switch to setTimeout(100ms) to ensure the editor focus
call happens after all pending focus transitions complete. This
matches the pattern already used in new-chat-form.tsx.

Also adds proper cleanup (clearTimeout) to the useEffect.
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