Skip to content

Commit

Permalink
Merge pull request #19506 from calixteman/bug1948741
Browse files Browse the repository at this point in the history
[Editor] Scale the signature editor when it's too large (bug 1948741)
  • Loading branch information
calixteman authored Feb 17, 2025
2 parents a0bdd67 + 3fc6b13 commit d010756
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/display/editor/signature.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ class SignatureEditor extends DrawingEditor {
newHeight = newHeight >= 1 ? 0.5 : newHeight;

this.width *= newHeight / this.height;
if (this.width >= 1) {
newHeight *= 0.9 / this.width;
this.width = 0.9;
}

this.height = newHeight;
this.setDims(parentWidth * this.width, parentHeight * this.height);
this.x = savedX;
Expand Down
43 changes: 43 additions & 0 deletions test/integration/signature_editor_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import {
closePages,
getEditorSelector,
getRect,
loadAndWait,
switchToEditor,
waitForTimeout,
Expand Down Expand Up @@ -207,4 +208,46 @@ describe("Signature Editor", () => {
);
});
});

describe("Bug 1948741", () => {
let pages;

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

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

it("must check that the editor isn't too large", async () => {
await Promise.all(
pages.map(async ([_, page]) => {
await switchToSignature(page);
await page.click("#editorSignatureAddSignature");

await page.waitForSelector("#addSignatureDialog", {
visible: true,
});
await page.type(
"#addSignatureTypeInput",
"[18:50:03] asset pdf.scripting.mjs 105 KiB [emitted] [javascript module] (name: main)"
);
await page.waitForSelector(`${addButtonSelector}:not(:disabled)`);
await page.click("#addSignatureAddButton");

const editorSelector = getEditorSelector(0);
await page.waitForSelector(editorSelector, { visible: true });
await page.waitForSelector(
`.canvasWrapper > svg use[href="#path_p1_0"]`,
{ visible: true }
);

const { width } = await getRect(page, editorSelector);
const { width: pageWidth } = await getRect(page, ".page");
expect(width).toBeLessThanOrEqual(pageWidth);
})
);
});
});
});

0 comments on commit d010756

Please sign in to comment.