1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-02-01 19:15:01 +02:00

Focus the editor whenever the user toggles the visible panes (#3646)

This commit is contained in:
Caleb John 2020-08-18 15:26:57 -06:00 committed by GitHub
parent 77c7f966cf
commit 0ae8d454ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -541,6 +541,18 @@ function CodeMirror(props: NoteBodyEditorProps, ref: any) {
return output;
}, [styles.cellViewer, props.visiblePanes]);
useEffect(() => {
if (!editorRef.current) return;
// Anytime the user toggles the visible panes AND the editor is visible as a result
// we should focus the editor
// The intuition is that a panel toggle (with editor in view) is the equivalent of
// an editor interaction so users should expect the editor to be focused
if (props.visiblePanes.indexOf('editor') >= 0) {
editorRef.current.focus();
}
}, [props.visiblePanes]);
useEffect(() => {
if (!editorRef.current) return;