Merge pull request #16940 from calixteman/get_back_focus_when_required

[Editor] Only get back the focus when it has been lost after an editor has been moved in the DOM
This commit is contained in:
calixteman 2023-09-12 13:22:47 +02:00 committed by GitHub
commit 953f271425
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -398,14 +398,18 @@ class AnnotationEditorLayer {
// re-enable them when the editor has the focus.
editor._focusEventsAllowed = false;
setTimeout(() => {
editor.div.addEventListener(
"focusin",
() => {
editor._focusEventsAllowed = true;
},
{ once: true }
);
activeElement.focus();
if (!editor.div.contains(document.activeElement)) {
editor.div.addEventListener(
"focusin",
() => {
editor._focusEventsAllowed = true;
},
{ once: true }
);
activeElement.focus();
} else {
editor._focusEventsAllowed = true;
}
}, 0);
}