Skip to content

Open-source document signature platform. Not affiliated with DocuSign.

TypeScript

Keep a page with no fields for the signer readable

Himanshu Mahto347183a83621
diff --git a/e2e/signing-page-without-fields.spec.ts b/e2e/signing-page-without-fields.spec.ts
new file mode 100644
index 0000000..b15dc41
--- /dev/null
+++ b/e2e/signing-page-without-fields.spec.ts
@@ -0,0 +1,108 @@
+import { expect, test } from "@playwright/test";
+
+import { signInAsAdministrator } from "./support/admin-session";
+import { extractLink, waitForEmail } from "./support/outbox";
+import { writeSamplePdf } from "./support/sample-pdf";
+
+// Runs after signing-flow.spec.ts, which sets up the install and its
+// administrator.
+
+const SIGNER_EMAIL = "[email protected]";
+
+test("a page with no fields for the signer stays readable", async ({
+ browser,
+ page,
+}, testInfo) => {
+ await test.step("the sender puts the only field on the last page", async () => {
+ await signInAsAdministrator(page);
+
+ const pdfPath = await writeSamplePdf(testInfo.outputPath("pages.pdf"));
+
+ await page.goto("/envelopes/new");
+ await page.getByLabel("Envelope title").fill("Field on the last page");
+ await page.getByLabel("Upload PDF").setInputFiles(pdfPath);
+ await page.getByRole("button", { name: "Next ->" }).click();
+ await expect(page).toHaveURL(/\/envelopes\/[^/]+\/signers$/);
+
+ await page.getByLabel("Signer 1 name").fill("Paige Pages");
+ await page.getByLabel("Signer 1 email").fill(SIGNER_EMAIL);
+ await page.getByRole("button", { name: "Next →" }).click();
+ await expect(page).toHaveURL(/\/prepare$/);
+
+ await page.getByRole("button", { name: "Next page" }).click();
+ await expect(page.getByText("Page 2 of 2")).toBeVisible();
+ await page.getByRole("button", { exact: true, name: "Signature" }).click();
+
+ const placementTarget = page.getByLabel("Place Signature on page 2");
+ const box = await placementTarget.boundingBox();
+
+ await placementTarget.click({
+ position: { x: box!.width * 0.3, y: box!.height * 0.75 },
+ });
+ await expect(page.getByRole("status")).toHaveText("Saved");
+ await page.getByRole("button", { name: "Next →" }).click();
+ await expect(page).toHaveURL(/\/review$/);
+ await page.getByRole("button", { name: "Send envelope" }).click();
+
+ const confirmation = page.getByRole("dialog", {
+ name: "Send this envelope?",
+ });
+
+ await confirmation.getByRole("checkbox").check();
+ await confirmation.getByRole("button", { name: "Send now" }).click();
+ await expect(page).toHaveURL(/\/envelopes\/[^/]+$/);
+ });
+
+ await test.step("page 1 shows the document, and the toolbar says it has no fields", async () => {
+ const invitation = await waitForEmail({
+ template: "signing_invitation",
+ to: SIGNER_EMAIL,
+ });
+ const signerContext = await browser.newContext({
+ viewport: { height: 900, width: 1440 },
+ });
+ const signerPage = await signerContext.newPage();
+
+ await signerPage.goto(extractLink(invitation.text, "/sign/"));
+
+ const consent = signerPage.getByRole("dialog", { name: "Before you sign" });
+
+ await consent
+ .getByRole("checkbox", {
+ name: "I agree to use electronic records and signatures",
+ })
+ .check();
+ await consent.getByRole("button", { name: "Agree and continue" }).click();
+ await expect(consent).toBeHidden();
+
+ // The page opens on the signer's field.
+ await expect(signerPage.getByText("Page 2 of 2")).toBeVisible();
+ await expect(signerPage.getByText("Current signer view")).toBeVisible();
+
+ await signerPage.getByRole("button", { name: "Previous page" }).click();
+ await expect(signerPage.getByText("Page 1 of 2")).toBeVisible();
+ await expect(signerPage.getByText("No fields on this page")).toBeVisible();
+ await expect(
+ signerPage.getByText("No signer fields on this page"),
+ ).toHaveCount(0);
+
+ // Nothing sits on top of the page: its middle is the document itself.
+ await expect
+ .poll(() =>
+ signerPage.evaluate(() => {
+ const viewport = document.querySelector("[data-field-viewport]");
+ const rect = viewport?.getBoundingClientRect();
+
+ return rect
+ ? document.elementFromPoint(
+ rect.left + rect.width / 2,
+ rect.top + rect.height / 2,
+ )?.tagName
+ : null;
+ }),
+ )
+ .toBe("CANVAS");
+
+ await signerContext.close();
+ });
+});
diff --git a/src/components/signing/signing-live-shell.tsx b/src/components/signing/signing-live-shell.tsx
index 197de9f..2de54bb 100644
--- a/src/components/signing/signing-live-shell.tsx
+++ b/src/components/signing/signing-live-shell.tsx
@@ -1083,6 +1083,11 @@ export function SigningLiveShell({
<div className="flex justify-center xl:justify-end">
<SigningToolbarStatus
hasLockedFields={pageVisibleFields.length > 0}
+ pageHasNoFields={
+ isDocumentReady &&
+ pageCurrentFields.length === 0 &&
+ pageVisibleFields.length === 0
+ }
remainingFields={remainingFields}
/>
</div>
@@ -1192,22 +1197,6 @@ export function SigningLiveShell({
/>
))
: null}
-
- {isDocumentReady &&
- pageCurrentFields.length === 0 &&
- pageVisibleFields.length === 0 ? (
- <div className="absolute inset-0 z-1 flex items-center justify-center px-6">
- <div className="max-w-[320px] rounded-[1.25rem] border-2 border-dashed border-(--border-strong) bg-white/92 px-6 py-7 text-center">
- <p className="text-lg font-extrabold tracking-[-0.02em] text-(--fg)">
- No signer fields on this page
- </p>
- <p className="mt-2 text-sm leading-6 text-(--secondary)">
- Move between pages to review your assigned fields
- and any completed values from earlier signers.
- </p>
- </div>
- </div>
- ) : null}
</div>
</div>
</div>
@@ -1597,9 +1586,11 @@ export function SigningLiveShell({
function SigningToolbarStatus({
hasLockedFields,
+ pageHasNoFields,
remainingFields,
}: {
hasLockedFields: boolean;
+ pageHasNoFields: boolean;
remainingFields: number;
}) {
return (
@@ -1640,7 +1631,11 @@ function SigningToolbarStatus({
: `${remainingFields} required remaining`}
</p>
<p className="text-xs leading-tight text-(--tertiary)">
- {hasLockedFields ? "Locked values visible" : "Current signer view"}
+ {pageHasNoFields
+ ? "No fields on this page"
+ : hasLockedFields
+ ? "Locked values visible"
+ : "Current signer view"}
</p>
</div>
</div>