Skip to content

Commit

Permalink
Merge pull request mozilla#16940 from calixteman/get_back_focus_when_…
Browse files Browse the repository at this point in the history
…required

[Editor] Only get back the focus when it has been lost after an editor has been moved in the DOM
  • Loading branch information
calixteman authored Sep 12, 2023
2 parents 221ee6c + 5646604 commit 953f271
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/display/editor/annotation_editor_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 953f271

Please sign in to comment.