From 57caa4601cdf5da873d048d1f51467ec49f8ca04 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Sat, 23 Sep 2023 23:53:19 +0200 Subject: [PATCH] [Editor] The ::before containter containing the border of a selected editor mustn't catch mouse events (bug 1854818) --- test/integration/freetext_editor_spec.js | 51 ++++++++++++++++++++++++ web/annotation_editor_layer_builder.css | 1 + 2 files changed, 52 insertions(+) diff --git a/test/integration/freetext_editor_spec.js b/test/integration/freetext_editor_spec.js index 830d3f3578e70..098dc3fa790c6 100644 --- a/test/integration/freetext_editor_spec.js +++ b/test/integration/freetext_editor_spec.js @@ -2478,4 +2478,55 @@ describe("FreeText Editor", () => { ); }); }); + + describe("Bug 1854818: mouse events in a selected FreeText editor", () => { + let pages; + + beforeAll(async () => { + pages = await loadAndWait("empty.pdf", ".annotationEditorLayer"); + }); + + afterAll(async () => { + await closePages(pages); + }); + + it("must check the text can be selected with the mouse", async () => { + await Promise.all( + pages.map(async ([browserName, page]) => { + await page.click("#editorFreeText"); + + const rect = await page.$eval(".annotationEditorLayer", el => { + // With Chrome something is wrong when serializing a DomRect, + // hence we extract the values and just return them. + const { x, y } = el.getBoundingClientRect(); + return { x, y }; + }); + + const data = "Hello PDF.js World !!"; + await page.mouse.click(rect.x + 100, rect.y + 100); + await page.waitForSelector(getEditorSelector(0), { + visible: true, + }); + const internalEditorSelector = `${getEditorSelector(0)} .internal`; + await page.type(internalEditorSelector, data); + await page.keyboard.press("Escape"); + await page.waitForSelector( + `${getEditorSelector(0)} .overlay.enabled` + ); + await page.click(getEditorSelector(0), { clickCount: 2 }); + await page.waitForSelector( + `${getEditorSelector(0)} .overlay:not(.enabled)` + ); + await page.click(internalEditorSelector, { + clickCount: 3, + }); + const selection = await page.evaluate(() => + window.getSelection().toString() + ); + + expect(selection).withContext(`In ${browserName}`).toEqual(data); + }) + ); + }); + }); }); diff --git a/web/annotation_editor_layer_builder.css b/web/annotation_editor_layer_builder.css index 66be0a0c38a6c..73d0dd8317d3f 100644 --- a/web/annotation_editor_layer_builder.css +++ b/web/annotation_editor_layer_builder.css @@ -169,6 +169,7 @@ position: absolute; inset: 0; border: var(--focus-outline-around); + pointer-events: none; } }