diff --git a/edit/sections.js b/edit/sections.js index 15be1684..a36960dc 100644 --- a/edit/sections.js +++ b/edit/sections.js @@ -65,7 +65,11 @@ function addSections(sections, onAdded = () => {}) { const isPageLocked = document.documentElement.style.pointerEvents; if (divs[0] && (isPageLocked ? divs.length === sections.length : index === 0)) { makeSectionVisible(divs[0].CodeMirror); - divs[0].CodeMirror.focus(); + setTimeout(() => { + if ((document.activeElement || {}).localName !== 'input') { + divs[0].CodeMirror.focus(); + } + }); } } } diff --git a/edit/source-editor.js b/edit/source-editor.js index 231901c9..f9139be1 100644 --- a/edit/source-editor.js +++ b/edit/source-editor.js @@ -43,8 +43,11 @@ function createSourceEditor(style) { initHooks(); initAppliesToLineWidget(); - // focus must be the last action, otherwise the style is duplicated on saving - cm.focus(); + setTimeout(() => { + if ((document.activeElement || {}).localName !== 'input') { + cm.focus(); + } + }); }); function initAppliesToLineWidget() {