@devries-cameron20 / t3code Mirror · read-only / commits / 63b5645678
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 11:00 UTC

fix(web): Esc in Clerk's account modal no longer closes Settings (#32859)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Pradip Chaudhary committed Nov 15, 2026 at 12:31 UTC 63b56456780e5010bde92c8892cc7a3653da23be
2 files changed +30 -1
apps/web/src/components/AppRouteModal.browser.test.tsx
+19
@@ -24,4 +24,23 @@ describe("AppRouteModal", () => {
24
25 expect(onCommit).toHaveBeenCalledWith("Keep titles short");
26 });
27 +
28 + it("stays open when Esc belongs to a modal outside Base UI", async () => {
29 + await using _screen = await render(
30 + <AppRouteModal label="Settings">
31 + <CommitOnBlurField onCommit={() => undefined} />
32 + </AppRouteModal>,
33 + { router: "/settings/general" },
34 + );
35 + // Clerk renders its account modal in its own root and dismisses on a document Esc listener.
36 + const foreignModal = document.body.appendChild(document.createElement("input"));
37 + using _foreignModal = { [Symbol.dispose]: () => foreignModal.remove() };
38 +
39 + foreignModal.focus();
40 + await userEvent.keyboard("{Escape}");
41 +
42 + await expect
43 + .element(page.getByRole("dialog", { name: "Settings" }))
44 + .toHaveAttribute("data-open");
45 + });
46 });
apps/web/src/components/AppRouteModal.tsx
+11 -1
@@ -31,8 +31,18 @@ export function AppRouteModal({ label, children }: { label: string; children: Re
31 open={open}
32 // Portaled layers outside this tree (toasts, Clerk, confirm dialogs) are not backdrop presses.
33 disablePointerDismissal
34 - onOpenChange={(nextOpen) => {
34 + onOpenChange={(nextOpen, eventDetails) => {
35 if (nextOpen) return;
36 + // Esc from a layer outside Base UI (Clerk's modals) is that layer's to handle.
37 + const target = eventDetails.event.target;
38 + if (
39 + eventDetails.reason === "escape-key" &&
40 + target !== document.body &&
41 + target instanceof Node &&
42 + !popupRef.current?.contains(target)
43 + ) {
44 + return eventDetails.cancel();
45 + }
46 // Closing unmounts a focused field without a blur, so commit-on-blur rows would
47 // drop what was typed. Blur first so they commit.
48 const focused = document.activeElement;