Skip to content

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

TypeScript

Decline confirmation: move focus to it, and claim only what is certain

Clauded7c02b3bff6e
diff --git a/e2e/signing-flow.spec.ts b/e2e/signing-flow.spec.ts
index f07e469..39e8656 100644
--- a/e2e/signing-flow.spec.ts
+++ b/e2e/signing-flow.spec.ts
@@ -1317,9 +1317,13 @@ test("a signer who declines is told the decline was recorded, not that the link
.fill("Terms in section 2 are not what we agreed.");
await decline.getByRole("button", { name: "Decline to sign" }).click();
- await expect(
- signerPage.getByRole("heading", { name: "You declined to sign" }),
- ).toBeVisible();
+ const declined = signerPage.getByRole("heading", {
+ name: "You declined to sign",
+ });
+
+ await expect(declined).toBeVisible();
+ // Focus moves to the outcome, so a screen reader reads it out.
+ await expect(declined).toBeFocused();
await expect(signerPage.getByText("This link has expired")).toHaveCount(0);
await expect(
signerPage.getByText(/Request a new signing link/),
diff --git a/src/components/signing/signing-live-shell.tsx b/src/components/signing/signing-live-shell.tsx
index f7f2eec..f7cddda 100644
--- a/src/components/signing/signing-live-shell.tsx
+++ b/src/components/signing/signing-live-shell.tsx
@@ -88,7 +88,7 @@ const defaultDeclineErrorMessage =
/** What a signer sees once their decline is recorded. */
export const declinedConfirmation = {
description:
- "Your decline has been recorded and the sender has been told. No further action is needed, and this link no longer opens the document.",
+ "Your decline has been recorded. No further action is needed, and this link no longer opens the document.",
title: "You declined to sign",
};
const compactFieldHeightThreshold = 0.045;
@@ -799,6 +799,7 @@ export function SigningLiveShell({
return (
<SigningStateScreen
description={declinedConfirmation.description}
+ focusHeading
title={declinedConfirmation.title}
/>
);
diff --git a/src/components/signing/signing-state-screen.tsx b/src/components/signing/signing-state-screen.tsx
index 032ac60..87105f1 100644
--- a/src/components/signing/signing-state-screen.tsx
+++ b/src/components/signing/signing-state-screen.tsx
@@ -1,6 +1,7 @@
"use client";
import { FileTextIcon } from "lucide-react";
+import { useEffect, useRef } from "react";
import { Brand } from "@/components/layout/brand";
import { PublicLegalFooter } from "@/components/layout/public-legal-links";
@@ -8,11 +9,26 @@ import { PublicLegalFooter } from "@/components/layout/public-legal-links";
/** A signing link's end state: a heading and one line, with no document. */
export function SigningStateScreen({
description,
+ focusHeading = false,
title,
}: {
description: string;
+ /**
+ * Moves focus to the heading when the screen appears in place of
+ * something the person was using (a dialog), so a screen reader reads
+ * the outcome out.
+ */
+ focusHeading?: boolean;
title: string;
}) {
+ const headingRef = useRef<HTMLHeadingElement>(null);
+
+ useEffect(() => {
+ if (focusHeading) {
+ headingRef.current?.focus();
+ }
+ }, [focusHeading]);
+
return (
<div className="flex min-h-screen flex-col">
<header>
@@ -31,7 +47,11 @@ export function SigningStateScreen({
>
<FileTextIcon className="size-6" strokeWidth={2.2} />
</span>
- <h1 className="mt-6 text-[clamp(1.625rem,4vw,2.125rem)] font-extrabold leading-tight tracking-[-0.03em] text-(--fg)">
+ <h1
+ className="mt-6 text-[clamp(1.625rem,4vw,2.125rem)] font-extrabold leading-tight tracking-[-0.03em] text-(--fg) outline-none"
+ ref={headingRef}
+ tabIndex={-1}
+ >
{title}
</h1>
<p className="mx-auto mt-3 max-w-[460px] text-base leading-7 text-(--secondary)">