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, 14:45 UTC
fix(web): picking a sidebar search result scrolls the list to that thread (#27109)
Co-authored-by: tsmith165 <16846767+tsmith165@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
tsmith165 committed
Nov 14, 2026 at 03:57 UTC
96735d7311d857728a3e1171ae651b7510814803
2 files changed
+46
-1
apps/web/src/components/Sidebar.drag.browser.test.tsx
+36
@@ -16,6 +16,8 @@ import {
16
type FakeDriver,
17
} from "../../test/fakeEnvironment";
18
import { act, render } from "../../test/render";
19
+import { makeThreadFixture } from "../test-fixtures";
20
+import { SidebarSearchResultRow } from "./sidebar/SidebarThreadRow";
21
22
// The socket is the only fake layer; see test/appScenarios.renders.tsx.
23
vi.mock("../../../../packages/client-runtime/src/connection/driver.ts", async (importOriginal) => {
@@ -86,3 +88,37 @@ it("keeps the title when dragging a search result from a collapsed folder", asyn
88
).toBe(second.title);
89
});
90
});
91
+
92
+it("keeps focus in the search box when a click picks a search result", async () => {
93
+ const onSelect = vi.fn();
94
+ await using screen = await render(
95
+ <>
96
+ <input aria-label="Search threads" />
97
+ <ul role="listbox">
98
+ <SidebarSearchResultRow
99
+ isSettled={false}
100
+ thread={makeThreadFixture({ title: "Invoice export" })}
101
+ project={null}
102
+ projectDisplayName={null}
103
+ environmentLabel={null}
104
+ environmentMachine="server"
105
+ providerEntryByInstanceId={new Map()}
106
+ isHighlighted={false}
107
+ isRouteActive={false}
108
+ resultId="result-0"
109
+ searchMatch={null}
110
+ searchQuery="invoice"
111
+ onHighlight={() => {}}
112
+ onSelect={onSelect}
113
+ onFileDropThreads={() => {}}
114
+ />
115
+ </ul>
116
+ </>,
117
+ );
118
+ const search = screen.getByRole("textbox", { name: "Search threads" });
119
+ await userEvent.click(search);
120
+ await userEvent.click(screen.getByRole("option"));
121
+ expect(onSelect).toHaveBeenCalledOnce();
122
+ // Picking clears the results; a focused result would drop focus, and its recovery scrolls the list.
123
+ await expect.element(search).toHaveFocus();
124
+});
apps/web/src/components/sidebar/SidebarThreadRow.tsx
+10
-1
@@ -1419,9 +1419,11 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
1419
data-thread-item={threadKey}
1420
{...sortableRootProps}
1421
{...(fileDropHandlers ?? {})}
1422
+ // The hints are the rendered heights inside py-0.5. Revealing the open thread measures rows
1423
+ // that have not rendered yet, so a hint off by a pixel lands it a pixel short per row above.
1424
className={cn(
1425
"list-none py-0.5 [content-visibility:auto] [contain-intrinsic-size:auto_78px]",
1424
- metaLineEmpty && "[contain-intrinsic-size:auto_58px]",
1426
+ metaLineEmpty && "[contain-intrinsic-size:auto_60px]",
1427
sortable?.isDragging && "relative z-20",
1428
)}
1429
>
@@ -1746,6 +1748,13 @@ export const SidebarSearchResultRow = memo(function SidebarSearchResultRow(props
1748
aria-label={accessibility.label}
1749
{...dragListeners}
1750
onMouseMove={props.onHighlight}
1751
+ // Focus stays in the search box, as for Enter. A focused result would lose focus as
1752
+ // the results close, and its recovery scrolls the list away from the opened thread.
1753
+ // dnd-kit ignores a prevented press, so the drag listener runs first.
1754
+ onPointerDown={(event) => {
1755
+ dragListeners?.onPointerDown?.(event);
1756
+ event.preventDefault();
1757
+ }}
1758
onClick={props.onSelect}
1759
className={cn(
1760
"group/sidebar-row group/v2-row flex min-h-9 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 py-1 text-left text-sm outline-none",