@devries-cameron20 / t3code Mirror · read-only / commits / 40d335a7ba
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 22, 13:15 UTC

fix(web): settling a thread no longer scrolls the sidebar to the bottom (#26392)

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

Theo Browne committed Oct 28, 2026 at 03:12 UTC 40d335a7ba8ed0e6158a400188b5ed174e6ed19b
2 files changed +21 -1
apps/web/src/lib/sidebarTree.browser.test.ts
+19
@@ -172,6 +172,25 @@ describe("sidebar keyboard navigation", () => {
172 expect([firstAction.tabIndex, secondAction.tabIndex]).toEqual([-1, 0]);
173 });
174
175 + it("keeps the scroll position when focus follows a row that moved away", async () => {
176 + using tree = setup();
177 + Object.assign(tree.root.style, { height: "100px", overflow: "auto" });
178 + const settled = tree.row("settled");
179 + const settle = document.createElement("button");
180 + settle.textContent = "Settle";
181 + settled.after(settle);
182 + settle.dataset.sidebarActionFor = "settled";
183 + for (let index = 0; index < 20; index++) tree.row(`row-${index}`).style.display = "block";
184 + tree.install();
185 + settle.focus();
186 + // Settling moves the row to the shelf at the bottom and removes the focused button.
187 + settle.remove();
188 + settled.remove();
189 + const moved = tree.row("settled");
190 + await vi.waitFor(() => expect(document.activeElement).toBe(moved));
191 + expect(tree.root.scrollTop).toBe(0);
192 + });
193 +
194 it("does not pull focus back after a click outside the tree", async () => {
195 using tree = setup();
196 const first = tree.row("first");
apps/web/src/lib/sidebarTree.ts
+2 -1
@@ -120,7 +120,8 @@ export function installSidebarTree(root: HTMLElement) {
120 !rows.includes(document.activeElement as HTMLElement) &&
121 document.activeElement?.matches(ROW)))
122 ) {
123 - focusRow(selected);
123 + // A settled row moves to the bottom shelf; scrolling after it fights the route reveal.
124 + selected.focus({ preventScroll: true });
125 }
126 if (ownsFocus && !selected && document.activeElement === document.body) root.focus();
127 };