File tree Expand file tree Collapse file tree
apps/code/src/renderer/features/terminal/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ export function Terminal({
5151 if ( ! terminalRef . current ) return ;
5252
5353 terminalManager . attach ( sessionId , terminalRef . current ) ;
54+ terminalManager . focus ( sessionId ) ;
5455
5556 return ( ) => {
5657 terminalManager . detach ( sessionId ) ;
@@ -111,12 +112,13 @@ export function Terminal({
111112 } ;
112113 } , [ sessionId , onReady , onExit ] ) ;
113114
114- const handleClick = useCallback ( ( ) => {
115+ // mousedown so the xterm textarea is focused before the browser's native focus shift, not after.
116+ const handleMouseDown = useCallback ( ( ) => {
115117 terminalManager . focus ( sessionId ) ;
116118 } , [ sessionId ] ) ;
117119
118120 return (
119- < Box onClick = { handleClick } className = "relative h-full p-3" >
121+ < Box onMouseDown = { handleMouseDown } className = "relative h-full p-3" >
120122 < div ref = { terminalRef } className = "h-full w-full" />
121123 < style >
122124 { `
You can’t perform that action at this time.
0 commit comments