From 56466048832b935e80c878c262e644861cfefe47 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Tue, 12 Sep 2023 12:17:24 +0200 Subject: [PATCH] [Editor] Only get back the focus when it has been lost after an editor has been moved in the DOM --- src/display/editor/annotation_editor_layer.js | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/display/editor/annotation_editor_layer.js b/src/display/editor/annotation_editor_layer.js index fc724cdc51214..ca1a8b0bc0304 100644 --- a/src/display/editor/annotation_editor_layer.js +++ b/src/display/editor/annotation_editor_layer.js @@ -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); }