diff --git a/services/web/frontend/js/features/pdf-preview/components/switch-to-editor-button.tsx b/services/web/frontend/js/features/pdf-preview/components/switch-to-editor-button.tsx index b3fd477373..dab10e8e80 100644 --- a/services/web/frontend/js/features/pdf-preview/components/switch-to-editor-button.tsx +++ b/services/web/frontend/js/features/pdf-preview/components/switch-to-editor-button.tsx @@ -20,6 +20,9 @@ function SwitchToEditorButton() { function handleClick() { setView('editor') + window.setTimeout(() => { + window.dispatchEvent(new Event('editor:focus')) + }) } return ( diff --git a/services/web/frontend/js/features/source-editor/hooks/use-codemirror-scope.ts b/services/web/frontend/js/features/source-editor/hooks/use-codemirror-scope.ts index 008f98f03e..46d15d4ab4 100644 --- a/services/web/frontend/js/features/source-editor/hooks/use-codemirror-scope.ts +++ b/services/web/frontend/js/features/source-editor/hooks/use-codemirror-scope.ts @@ -576,6 +576,13 @@ function useCodeMirrorScope(view: EditorView) { useEventListener('learnedWords:reset', handleResetLearnedWords) + useEventListener( + 'editor:focus', + useCallback(() => { + view.focus() + }, [view]) + ) + useEffect(() => { view.dispatch(reviewPanelToggled()) }, [reviewPanelOpen, miniReviewPanelVisible, view])