@devries-cameron20 / t3code-1 / commits / 9d6a2e57fc
Fork 0

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

fix(web): new thread shortcut focuses palette search, not the Back button (#25315)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Theo Browne committed Oct 25, 2026 at 21:42 UTC 9d6a2e57fce3fd397a7286740351a1aef7b81453
2 files changed +52
apps/web/src/components/CommandPaletteContent.browser.test.tsx new
+47
@@ -0,0 +1,47 @@
1 +import { useState } from "react";
2 +import { describe, expect, it } from "vite-plus/test";
3 +import { page, userEvent } from "vite-plus/test/browser";
4 +
5 +import { render } from "../../test/render";
6 +import { CommandPaletteContent } from "./CommandPaletteContent";
7 +import { CommandDialog, CommandDialogPopup, CommandItem, CommandList } from "./ui/command";
8 +
9 +function SubmenuPalette() {
10 + const [open, setOpen] = useState(false);
11 + return (
12 + <>
13 + <button type="button" onClick={() => setOpen(true)}>
14 + Open
15 + </button>
16 + <CommandDialog open={open} onOpenChange={setOpen}>
17 + <CommandDialogPopup aria-label="Command palette">
18 + <CommandPaletteContent
19 + items={["Project A"]}
20 + inputProps={{
21 + placeholder: "Search projects",
22 + startAddon: (
23 + <button type="button" aria-label="Back">
24 + Back
25 + </button>
26 + ),
27 + }}
28 + >
29 + <CommandList>
30 + {(item: string) => <CommandItem value={item}>{item}</CommandItem>}
31 + </CommandList>
32 + </CommandPaletteContent>
33 + </CommandDialogPopup>
34 + </CommandDialog>
35 + </>
36 + );
37 +}
38 +
39 +describe("CommandPaletteContent", () => {
40 + it("focuses the search input, not the Back button, when it opens into a submenu", async () => {
41 + await using _screen = await render(<SubmenuPalette />);
42 +
43 + await userEvent.click(page.getByRole("button", { name: "Open" }));
44 +
45 + await expect.element(page.getByPlaceholder("Search projects")).toHaveFocus();
46 + });
47 +});
apps/web/src/components/ui/command.tsx
+5
@@ -1,5 +1,6 @@
1 import { Dialog as CommandDialogPrimitive } from "@base-ui/react/dialog";
2 import { SearchIcon } from "lucide-react";
3 +import { useRef } from "react";
4 import type * as React from "react";
5 import { cn } from "~/lib/utils";
6 import {
@@ -55,11 +56,15 @@ function CommandDialogPopup({
56 }: CommandDialogPrimitive.Popup.Props & {
57 onBackdropPointerDown?: React.PointerEventHandler<HTMLDivElement>;
58 }) {
59 + const popupRef = useRef<HTMLDivElement>(null);
60 return (
61 <CommandDialogPortal>
62 <CommandDialogBackdrop onPointerDown={onBackdropPointerDown} />
63 <CommandDialogViewport>
64 <CommandDialogPrimitive.Popup
65 + // The first tabbable can be an input addon, such as a submenu's Back button.
66 + initialFocus={() => popupRef.current?.querySelector("input") ?? true}
67 + ref={popupRef}
68 className={cn(
69 DIALOG_POPUP_CLASS,
70 "pointer-events-auto max-h-105 max-w-xl text-foreground",