From afa1e7974ae6629c94e66469e47a8fc004c5039e Mon Sep 17 00:00:00 2001 From: Gazook89 Date: Mon, 2 Sep 2024 21:07:19 -0500 Subject: [PATCH 1/2] Set focus on editor after tab switch This sets the focus on the editor (and thus reveals cursor position) between editor changes (style to text to meta and back). --- client/homebrew/editor/editor.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 364ed424a..0cc31cb40 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -82,6 +82,7 @@ const Editor = createClass({ if(prevProps.moveSource !== this.props.moveSource) { this.sourceJump(); }; + this.codeEditor.current?.codeMirror.focus(); }, handleControlKeys : function(e){ From 3c6f49aa0a5bd3632ec2187db81d77c97406c8b9 Mon Sep 17 00:00:00 2001 From: Gazook89 Date: Tue, 3 Sep 2024 14:48:45 -0500 Subject: [PATCH 2/2] Move focus method to handleViewChange --- client/homebrew/editor/editor.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 0cc31cb40..24e975ebc 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -82,7 +82,6 @@ const Editor = createClass({ if(prevProps.moveSource !== this.props.moveSource) { this.sourceJump(); }; - this.codeEditor.current?.codeMirror.focus(); }, handleControlKeys : function(e){ @@ -114,7 +113,10 @@ const Editor = createClass({ this.props.setMoveArrows(newView === 'text'); this.setState({ view : newView - }, this.updateEditorSize); //TODO: not sure if updateeditorsize needed + }, ()=>{ + this.codeEditor.current?.codeMirror.focus(); + this.updateEditorSize(); + }); //TODO: not sure if updateeditorsize needed }, getCurrentPage : function(){