From 42147e88398a77394f06563765953da7f5cb3f11 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Fri, 24 Nov 2023 16:00:00 +0100 Subject: [PATCH] [Editor] Only focus the canvas for mouse events when drawing in the canvas And if we've to focus it, we must prevent scrolling to avoid to draw at an unexpected position. --- src/display/editor/ink.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/display/editor/ink.js b/src/display/editor/ink.js index cc5288706..adb92fd59 100644 --- a/src/display/editor/ink.js +++ b/src/display/editor/ink.js @@ -660,8 +660,13 @@ class InkEditor extends AnnotationEditor { event.preventDefault(); - if (event.type !== "mouse") { - this.div.focus(); + if ( + event.pointerType !== "mouse" && + !this.div.contains(document.activeElement) + ) { + this.div.focus({ + preventScroll: true /* See issue #17327 */, + }); } this.#startDrawing(event.offsetX, event.offsetY);