From e60996b86c734a3064274635ebad2fd35f725566 Mon Sep 17 00:00:00 2001 From: Martin Fournier Date: Mon, 20 Dec 2021 07:15:53 -0500 Subject: [PATCH] Focus editor when opening or changing tabs --- src/ScriptEditor/ui/ScriptEditorRoot.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ScriptEditor/ui/ScriptEditorRoot.tsx b/src/ScriptEditor/ui/ScriptEditorRoot.tsx index fc32a7625..2b66fc0e6 100644 --- a/src/ScriptEditor/ui/ScriptEditorRoot.tsx +++ b/src/ScriptEditor/ui/ScriptEditorRoot.tsx @@ -291,6 +291,8 @@ export function Root(props: IProps): React.ReactElement { editorRef.current.revealLineInCenter(currentScript.lastPosition.lineNumber); updateRAM(currentScript.code); } + + editorRef.current.focus(); } function infLoop(newCode: string): void { @@ -505,6 +507,7 @@ export function Root(props: IProps): React.ReactElement { editorRef.current.setPosition(openScripts[index].lastPosition); editorRef.current.revealLineInCenter(openScripts[index].lastPosition.lineNumber); updateRAM(openScripts[index].code); + editorRef.current.focus(); } } @@ -550,6 +553,7 @@ export function Root(props: IProps): React.ReactElement { editorRef.current.setModel(openScripts[index + indexOffset].model); editorRef.current.setPosition(openScripts[index + indexOffset].lastPosition); editorRef.current.revealLineInCenter(openScripts[index + indexOffset].lastPosition.lineNumber) + editorRef.current.focus(); } } else { // No more scripts are open