Open-source document signature platform. Not affiliated with DocuSign.
TypeScript
Close the phone Field tools sheet when the window grows to the desktop layout
Claude85e2bc6aff91
diff --git a/e2e/wizard-field-tools-sheet.spec.ts b/e2e/wizard-field-tools-sheet.spec.tsindex 96bdb59..2c5f4ff 100644--- a/e2e/wizard-field-tools-sheet.spec.ts+++ b/e2e/wizard-field-tools-sheet.spec.ts@@ -99,4 +99,18 @@ test("on a short phone the Field tools sheet keeps Done in view, and Escape clos).toHaveAttribute("aria-pressed", "false");await done.click();await expect(openTools).toBeFocused();++ // Growing the window to the desktop layout, which hides the sheet, closes+ // it, so it no longer holds Tab or Escape.+ await openTools.click();+ await expect(sheet).toBeVisible();+ await page.setViewportSize({ height: 900, width: 1440 });+ await page.evaluate(+ () =>+ new Promise((resolve) =>+ requestAnimationFrame(() => requestAnimationFrame(resolve)),+ ),+ );+ await page.setViewportSize({ height: 844, width: 390 });+ await expect(sheet).toBeHidden();});diff --git a/src/components/envelopes/prepare-live-shell.tsx b/src/components/envelopes/prepare-live-shell.tsxindex 11293f3..39887f6 100644--- a/src/components/envelopes/prepare-live-shell.tsx+++ b/src/components/envelopes/prepare-live-shell.tsx@@ -1232,10 +1232,23 @@ function MobileFieldToolsSheet({}}+ // The sheet is hidden (lg:hidden) on the desktop layout but would stay+ // mounted, its listener still catching Tab and Escape. So it closes when+ // the window grows to that layout.+ const desktopLayout = window.matchMedia("(min-width: 64rem)");++ function handleLayoutChange(event: MediaQueryListEvent) {+ if (event.matches) {+ onCloseRef.current();+ }+ }+document.addEventListener("keydown", handleKeyDown);+ desktopLayout.addEventListener("change", handleLayoutChange);return () => {document.removeEventListener("keydown", handleKeyDown);+ desktopLayout.removeEventListener("change", handleLayoutChange);returnFocusTo?.focus();};}, [returnFocusRef]);