From 6b545d666efed8a7387160ce6448e47adc44c19a Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Tue, 25 Jul 2023 19:00:05 +0200 Subject: [PATCH] [Editor] Avoid to trigger an editor creation when pinching on a touch screen --- src/display/editor/annotation_editor_layer.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/display/editor/annotation_editor_layer.js b/src/display/editor/annotation_editor_layer.js index c6fd7f2b6..8bb812c7a 100644 --- a/src/display/editor/annotation_editor_layer.js +++ b/src/display/editor/annotation_editor_layer.js @@ -553,6 +553,15 @@ class AnnotationEditorLayer { * @param {PointerEvent} event */ pointerdown(event) { + if (this.#hadPointerDown) { + // It's possible to have a second pointerdown event before a pointerup one + // when the user puts a finger on a touchscreen and then add a second one + // to start a pinch-to-zoom gesture. + // That said, in case it's possible to have two pointerdown events with + // a mouse, we don't want to create a new editor in such a case either. + this.#hadPointerDown = false; + return; + } const { isMac } = FeatureTest.platform; if (event.button !== 0 || (event.ctrlKey && isMac)) { // Do nothing on right click.