Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Editor] Unselect highlights when the user click on the text layer (bug 1869767) #17543

Merged
merged 1 commit into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/display/editor/annotation_editor_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ class AnnotationEditorLayer {
}

#textLayerPointerDown(event) {
// Unselect all the editors in order to let the user select some text
// without being annoyed by an editor toolbar.
this.#uiManager.unselectAll();
if (event.target === this.#textLayer.div) {
const { isMac } = FeatureTest.platform;
if (event.button !== 0 || (event.ctrlKey && isMac)) {
Expand Down
38 changes: 38 additions & 0 deletions test/integration/highlight_editor_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -530,4 +530,42 @@ describe("Highlight Editor", () => {
);
});
});

describe("Color picker can annoy the user when selecting some text", () => {
let pages;

beforeAll(async () => {
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
});

afterAll(async () => {
await closePages(pages);
});

it("must check that editor is unselected when the mouse is down on the text layer", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await page.click("#editorHighlight");
await page.waitForSelector(".annotationEditorLayer.highlightEditing");
const sel = getEditorSelector(0);

const rect = await getSpanRectFromText(page, 1, "Abstract");
const x = rect.x + rect.width / 2;
const y = rect.y + rect.height / 2;
await page.mouse.click(x, y, { count: 2 });

await page.waitForSelector(sel);
await page.waitForSelector(
`.page[data-page-number = "1"] svg.highlightOutline.selected`
);

await page.waitForSelector(`${sel} .editToolbar button.colorPicker`);
await page.mouse.click(x, y - rect.height);
await page.waitForSelector(
`.page[data-page-number = "1"] svg.highlightOutline:not(.selected)`
);
})
);
});
});
});