@devries-cameron20 / t3code-1 / commits / f8278d8516
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): keep typed Settings text when Esc closes Settings (#25131)

Co-authored-by: Aatman Jain <lives@MacBook-Pro.local> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>

Aatman Jain (AJ) committed Oct 30, 2026 at 21:10 UTC f8278d85160907d9afaa8aa435319b9aa8459284
2 files changed +33 -1
apps/web/src/components/AppRouteModal.browser.test.tsx new
+27
@@ -0,0 +1,27 @@
1 +import { describe, expect, it, vi } from "vite-plus/test";
2 +import { page, userEvent } from "vite-plus/test/browser";
3 +
4 +import { render } from "../../test/render";
5 +import { useCommitOnBlur } from "../hooks/useCommitOnBlur";
6 +import { AppRouteModal } from "./AppRouteModal";
7 +
8 +function CommitOnBlurField({ onCommit }: { onCommit: (next: string) => void }) {
9 + return <input aria-label="Instructions" {...useCommitOnBlur("", onCommit)} />;
10 +}
11 +
12 +describe("AppRouteModal", () => {
13 + it("commits a focused field when Esc closes it", async () => {
14 + const onCommit = vi.fn();
15 + await using _screen = await render(
16 + <AppRouteModal label="Settings">
17 + <CommitOnBlurField onCommit={onCommit} />
18 + </AppRouteModal>,
19 + { router: "/settings/general" },
20 + );
21 +
22 + await page.getByRole("textbox", { name: "Instructions" }).fill("Keep titles short");
23 + await userEvent.keyboard("{Escape}");
24 +
25 + expect(onCommit).toHaveBeenCalledWith("Keep titles short");
26 + });
27 +});
apps/web/src/components/AppRouteModal.tsx
+6 -1
@@ -27,7 +27,12 @@ export function AppRouteModal({ label, children }: { label: string; children: Re
27 // Portaled layers outside this tree (toasts, Clerk, confirm dialogs) are not backdrop presses.
28 disablePointerDismissal
29 onOpenChange={(nextOpen) => {
30 - if (!nextOpen) setOpen(false);
30 + if (nextOpen) return;
31 + // Closing unmounts a focused field without a blur, so commit-on-blur rows would
32 + // drop what was typed. Blur first so they commit.
33 + const focused = document.activeElement;
34 + if (focused instanceof HTMLElement && popupRef.current?.contains(focused)) focused.blur();
35 + setOpen(false);
36 }}
37 onOpenChangeComplete={(nextOpen) => {
38 if (!nextOpen) void closeAppModal();