Skip to content

Commit

Permalink
Merge pull request #19338 from avdoseferovic/fix/ink-editor-jumping
Browse files Browse the repository at this point in the history
[Editor] Don't scroll when drawing (issue 17327)
  • Loading branch information
calixteman authored Jan 23, 2025
2 parents 30fa7c3 + 78f612f commit f798bad
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/display/editor/annotation_editor_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,9 @@ class AnnotationEditorLayer {
}

startDrawingSession(event) {
this.div.focus();
this.div.focus({
preventScroll: true,
});
if (this.#drawingAC) {
this.#currentEditorType.startDrawing(this, this.#uiManager, false, event);
return;
Expand Down
50 changes: 50 additions & 0 deletions test/integration/ink_editor_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1075,4 +1075,54 @@ describe("Ink Editor", () => {
);
});
});

describe("Page position should remain unchanged after drawing", () => {
let pages;

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

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

it("must check that the page position remains the same after drawing", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
const pageInitialPosition = await getRect(
page,
".page[data-page-number='1']"
);

await switchToInk(page);

const editorLayerRect = await getRect(page, ".annotationEditorLayer");
const drawStartX = editorLayerRect.x + 100;
const drawStartY = editorLayerRect.y + 100;

const clickHandle = await waitForPointerUp(page);
await page.mouse.move(drawStartX, drawStartY);
await page.mouse.down();
await page.mouse.move(drawStartX + 50, drawStartY + 50);
await page.mouse.up();
await awaitPromise(clickHandle);
await commit(page);

const pageFinalPosition = await getRect(
page,
".page[data-page-number='1']"
);

expect(pageInitialPosition.x)
.withContext(`In ${browserName}`)
.toEqual(pageFinalPosition.x);

expect(pageInitialPosition.y)
.withContext(`In ${browserName}`)
.toEqual(pageFinalPosition.y);
})
);
});
});
});

0 comments on commit f798bad

Please sign in to comment.