don't steal focus from the find input on page open

This commit is contained in:
tophf 2017-12-11 08:32:11 +03:00
parent 180e813ac4
commit 60a5fb96be
2 changed files with 10 additions and 3 deletions

View File

@ -65,8 +65,12 @@ function addSections(sections, onAdded = () => {}) {
const isPageLocked = document.documentElement.style.pointerEvents; const isPageLocked = document.documentElement.style.pointerEvents;
if (divs[0] && (isPageLocked ? divs.length === sections.length : index === 0)) { if (divs[0] && (isPageLocked ? divs.length === sections.length : index === 0)) {
makeSectionVisible(divs[0].CodeMirror); makeSectionVisible(divs[0].CodeMirror);
setTimeout(() => {
if ((document.activeElement || {}).localName !== 'input') {
divs[0].CodeMirror.focus(); divs[0].CodeMirror.focus();
} }
});
}
} }
} }

View File

@ -43,8 +43,11 @@ function createSourceEditor(style) {
initHooks(); initHooks();
initAppliesToLineWidget(); initAppliesToLineWidget();
// focus must be the last action, otherwise the style is duplicated on saving setTimeout(() => {
if ((document.activeElement || {}).localName !== 'input') {
cm.focus(); cm.focus();
}
});
}); });
function initAppliesToLineWidget() { function initAppliesToLineWidget() {