From 71ca249d2bae862b1e56107d291041ed83088715 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Wed, 10 Aug 2022 10:05:04 +0200 Subject: [PATCH] [Editor] Avoid creation of an editor on "wrong" clicks --- src/display/editor/annotation_editor_layer.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/display/editor/annotation_editor_layer.js b/src/display/editor/annotation_editor_layer.js index cb07e47e7..4f3107956 100644 --- a/src/display/editor/annotation_editor_layer.js +++ b/src/display/editor/annotation_editor_layer.js @@ -49,6 +49,8 @@ class AnnotationEditorLayer { #editors = new Map(); + #hadPointerDown = false; + #isCleaningUp = false; #textLayerMap = new WeakMap(); @@ -597,6 +599,15 @@ class AnnotationEditorLayer { return; } + if (!this.#hadPointerDown) { + // It can happen when the user starts a drag inside a text editor + // and then releases the mouse button outside of it. In such a case + // we don't want to create a new editor, hence we check that a pointerdown + // occured on this div previously. + return; + } + this.#hadPointerDown = false; + if (!this.#allowClick) { this.#allowClick = true; return; @@ -620,6 +631,8 @@ class AnnotationEditorLayer { return; } + this.#hadPointerDown = true; + const editor = this.#uiManager.getActive(); this.#allowClick = !editor || editor.isEmpty(); }