Skip to content

Commit

Permalink
Merge pull request mozilla#17019 from calixteman/bug1854818
Browse files Browse the repository at this point in the history
[Editor] The ::before containter containing the border of a selected editor mustn't catch mouse events (bug 1854818)
  • Loading branch information
Snuffleupagus authored Sep 24, 2023
2 parents 587a3a2 + 57caa46 commit 57f548c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
51 changes: 51 additions & 0 deletions test/integration/freetext_editor_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
);
});
});
});
1 change: 1 addition & 0 deletions web/annotation_editor_layer_builder.css
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
position: absolute;
inset: 0;
border: var(--focus-outline-around);
pointer-events: none;
}
}

Expand Down

0 comments on commit 57f548c

Please sign in to comment.