Skip to content

Commit

Permalink
Keeping focus within Grist document when switching to an empty document
Browse files Browse the repository at this point in the history
  • Loading branch information
berhalak committed Sep 25, 2022
1 parent a8f000f commit 18ee361
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion markdown/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@
document.querySelector(".save-action").style.display = 'inline-block';
if (txt.isPreviewActive()) {
txt.togglePreview();
// We are using internals here to focus inner code editor.
// Focus on the editor, but only if we have focus on the window itself,
// We don't want to steel focus from a table in Grist.
if (!document.hasFocus()) {
return;
}
// Warning: We are using internals here to focus on the inner code editor,
// it might break in future easymde version.
if (txt.codemirror && typeof txt.codemirror.focus === 'function') {
txt.codemirror.focus();
}
Expand Down

0 comments on commit 18ee361

Please sign in to comment.