Skip to content

Commit

Permalink
Merge pull request #17370 from calixteman/issue17368
Browse files Browse the repository at this point in the history
[Editor] Make sure that all layers are disabled when an editing session is done
  • Loading branch information
calixteman authored Dec 4, 2023
2 parents 476cb84 + 43eea0b commit a3637e6
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/display/editor/annotation_editor_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ class AnnotationEditorLayer {
updateMode(mode = this.#uiManager.getMode()) {
this.#cleanup();
switch (mode) {
case AnnotationEditorType.NONE:
this.disableTextSelection();
this.togglePointerEvents(false);
this.disableClick();
break;
case AnnotationEditorType.INK:
// We always want to have an ink editor ready to draw in.
this.addInkEditorIfNeeded(false);
Expand Down
63 changes: 63 additions & 0 deletions test/integration/ink_editor_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
kbSelectAll,
kbUndo,
loadAndWait,
scrollIntoView,
waitForStorageEntries,
} from "./test_utils.mjs";

Expand Down Expand Up @@ -193,4 +194,66 @@ describe("Ink Editor", () => {
);
});
});

describe("Invisible layers must be disabled", () => {
let pages;

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

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

it("must check that the editor layer is disabled", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await page.click("#editorInk");
await page.waitForSelector(".annotationEditorLayer.inkEditing");

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 x = rect.x + 20;
const y = rect.y + 20;
const clickPromise = waitForPointerUp(page);
await page.mouse.move(x, y);
await page.mouse.down();
await page.mouse.move(x + 50, y + 50);
await page.mouse.up();
await clickPromise;

await commit(page);

const oneToFourteen = Array.from(new Array(13).keys(), n => n + 2);
for (const pageNumber of oneToFourteen) {
await scrollIntoView(
page,
`.page[data-page-number = "${pageNumber}"]`
);
}

await page.click("#editorInk");
await page.waitForSelector(".annotationEditorLayer:not(.inkEditing)");

const fourteenToOne = Array.from(new Array(13).keys(), n => 13 - n);
for (const pageNumber of fourteenToOne) {
await scrollIntoView(
page,
`.page[data-page-number = "${pageNumber}"]`
);
}

await page.waitForSelector(
`.page[data-page-number = "1"] .annotationEditorLayer.disabled:not(.inkEditing)`
);
})
);
});
});
});

0 comments on commit a3637e6

Please sign in to comment.