Skip to content

Commit 57f548c

Browse files
Merge pull request #17019 from calixteman/bug1854818
[Editor] The ::before containter containing the border of a selected editor mustn't catch mouse events (bug 1854818)
2 parents 587a3a2 + 57caa46 commit 57f548c

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

test/integration/freetext_editor_spec.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2478,4 +2478,55 @@ describe("FreeText Editor", () => {
24782478
);
24792479
});
24802480
});
2481+
2482+
describe("Bug 1854818: mouse events in a selected FreeText editor", () => {
2483+
let pages;
2484+
2485+
beforeAll(async () => {
2486+
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
2487+
});
2488+
2489+
afterAll(async () => {
2490+
await closePages(pages);
2491+
});
2492+
2493+
it("must check the text can be selected with the mouse", async () => {
2494+
await Promise.all(
2495+
pages.map(async ([browserName, page]) => {
2496+
await page.click("#editorFreeText");
2497+
2498+
const rect = await page.$eval(".annotationEditorLayer", el => {
2499+
// With Chrome something is wrong when serializing a DomRect,
2500+
// hence we extract the values and just return them.
2501+
const { x, y } = el.getBoundingClientRect();
2502+
return { x, y };
2503+
});
2504+
2505+
const data = "Hello PDF.js World !!";
2506+
await page.mouse.click(rect.x + 100, rect.y + 100);
2507+
await page.waitForSelector(getEditorSelector(0), {
2508+
visible: true,
2509+
});
2510+
const internalEditorSelector = `${getEditorSelector(0)} .internal`;
2511+
await page.type(internalEditorSelector, data);
2512+
await page.keyboard.press("Escape");
2513+
await page.waitForSelector(
2514+
`${getEditorSelector(0)} .overlay.enabled`
2515+
);
2516+
await page.click(getEditorSelector(0), { clickCount: 2 });
2517+
await page.waitForSelector(
2518+
`${getEditorSelector(0)} .overlay:not(.enabled)`
2519+
);
2520+
await page.click(internalEditorSelector, {
2521+
clickCount: 3,
2522+
});
2523+
const selection = await page.evaluate(() =>
2524+
window.getSelection().toString()
2525+
);
2526+
2527+
expect(selection).withContext(`In ${browserName}`).toEqual(data);
2528+
})
2529+
);
2530+
});
2531+
});
24812532
});

web/annotation_editor_layer_builder.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@
169169
position: absolute;
170170
inset: 0;
171171
border: var(--focus-outline-around);
172+
pointer-events: none;
172173
}
173174
}
174175

0 commit comments

Comments
 (0)