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, 08:15 UTC
fix(web): clicking a file in the Files tree keeps focus on that row (#28521)
Shkumbin Hasani committed
Nov 1, 2026 at 22:54 UTC
433bff1e305ecd2242a62bda1fe25f3d89e73057
2 files changed
+24
apps/web/src/lib/workspaceFocus.browser.test.ts
+23
@@ -226,6 +226,29 @@ describe("workspace area focus", () => {
226
await vi.waitFor(() => expect(document.activeElement).toBe(composer.button));
227
});
228
229
+ it("keeps focus on the control a panel tab switch came from", () => {
230
+ using fixture = setup();
231
+ const panel = fixture.area("panel", 3);
232
+ const content = document.createElement("div");
233
+ content.setAttribute("data-right-panel-surface-content", "");
234
+ const row = (name: string) => {
235
+ const button = document.createElement("button");
236
+ button.textContent = name;
237
+ content.append(button);
238
+ return button;
239
+ };
240
+ const earlierRow = row("reference-analysis.md");
241
+ const clickedRow = row("print-guide.md");
242
+ panel.element.append(content);
243
+ panel.element.dataset.workspaceFocusKey = "panel:file:print-guide.md";
244
+ earlierRow.focus();
245
+ panel.element.dataset.workspaceFocusKey = "panel:file:reference-analysis.md";
246
+ clickedRow.focus();
247
+ panel.element.dataset.workspaceFocusKey = "panel:file:print-guide.md";
248
+ expect(fixture.controller.focus("panel")).toBe(true);
249
+ expect(document.activeElement).toBe(clickedRow);
250
+ });
251
+
252
it("waits for a requested area to mount", async () => {
253
using fixture = setup();
254
fixture.area("composer", 2);
apps/web/src/lib/workspaceFocus.ts
+1
@@ -186,6 +186,7 @@ export function createWorkspaceFocusController(doc: Document) {
186
// A lazy surface's Suspense fallback is empty. Wait for its content instead
187
// of claiming focus on the tab strip before the useful controls mount.
188
if (surface && !surface.hasChildNodes()) return false;
189
+ if (!selector && surface?.contains(doc.activeElement)) return true;
190
if (selector) {
191
const target = area.querySelector<HTMLElement>(selector);
192
if (!target || !isWorkspaceElementVisible(target)) return false;