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,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();
}
});
}
}
}

View File

@ -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() {