From 60dd8147c66cc877ca7cf3431bda3932be159a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 13 Jan 2025 11:51:57 +0100 Subject: [PATCH] Enable editor when double-clicking on stamp annotation In Firefox, double-clicking on a stamp annotation triggers text selection (selecting the last text element in the dom before the annotation): this triggers the logic to make annotations not interfere with text selection, which in turns prevents the double click from triggering the annotation editor. This commit fixes the problem by making annotations non-selectable, so that clicking on them does not trigger text selection. Freetext annotations were already non-selectable, so this commit doesn't change that. However, we need to explicitly mark text in popups as selectable. --- test/integration/stamp_editor_spec.mjs | 31 ++++++++++++++++++++++++++ web/annotation_layer_builder.css | 3 ++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/test/integration/stamp_editor_spec.mjs b/test/integration/stamp_editor_spec.mjs index afbc1e6be..edb01595e 100644 --- a/test/integration/stamp_editor_spec.mjs +++ b/test/integration/stamp_editor_spec.mjs @@ -1814,4 +1814,35 @@ describe("Stamp Editor", () => { ); }); }); + + describe("Switch to edit mode by double clicking on an existing stamp annotation", () => { + const annotationSelector = getAnnotationSelector("999R"); + + let pages; + + beforeAll(async () => { + pages = await loadAndWait("issue19239.pdf", annotationSelector); + }); + + afterAll(async () => { + await closePages(pages); + }); + + it("must switch to edit mode", async () => { + await Promise.all( + pages.map(async ([, page]) => { + await page.waitForSelector(annotationSelector); + await scrollIntoView(page, annotationSelector); + + await page.click(annotationSelector, { count: 2 }); + + await page.waitForFunction(() => + document + .querySelector(".annotationEditorLayer") + .classList.contains("stampEditing") + ); + }) + ); + }); + }); }); diff --git a/web/annotation_layer_builder.css b/web/annotation_layer_builder.css index 3047adbb2..21c953b4f 100644 --- a/web/annotation_layer_builder.css +++ b/web/annotation_layer_builder.css @@ -108,7 +108,6 @@ white-space: nowrap; font: 10px sans-serif; line-height: 1.35; - user-select: none; } } @@ -118,6 +117,7 @@ pointer-events: auto; box-sizing: border-box; transform-origin: 0 0; + user-select: none; &:has(div.annotationContent) { canvas.annotationContent { @@ -315,6 +315,7 @@ white-space: normal; word-wrap: break-word; pointer-events: auto; + user-select: text; } .popupAnnotation.focused .popup {