Skip to content

Commit 2c706af

Browse files
juliusmarmingeclaude
authored andcommitted
fix(web): F6 onto the only, already focused area shows its ring
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent bdaa27e commit 2c706af

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

‎apps/web/src/lib/workspaceFocus.browser.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,5 +331,12 @@ describe("workspace area focus", () => {
331331

332332
await userEvent.click(home);
333333
expect(outline(), "clicking the ringed area removes its ring").toBe("none");
334+
335+
// With no other area visible, F6 lands on the area that already has focus.
336+
sidebar.element.hidden = true;
337+
await userEvent.keyboard("{F6}");
338+
fixture.controller.move(1);
339+
expect(document.activeElement).toBe(home);
340+
expect(outline(), "F6 onto the only, already focused area shows no ring").toBe("solid");
334341
});
335342
});

‎apps/web/src/lib/workspaceFocus.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ export function createWorkspaceFocusController(doc: Document) {
9898
keyboardArea?.removeAttribute("data-workspace-keyboard-focus");
9999
keyboardArea = undefined;
100100
};
101+
const markKeyboardArea = (area: HTMLElement) => {
102+
if (!area.matches(":focus-visible")) return;
103+
keyboardArea = area;
104+
area.setAttribute("data-workspace-keyboard-focus", "");
105+
};
101106
const remember = (event: FocusEvent) => {
102107
if (event.target !== keyboardArea) unmarkKeyboardArea();
103108
// Window activation refocuses the same element; only focus arriving from elsewhere counts.
@@ -106,10 +111,7 @@ export function createWorkspaceFocusController(doc: Document) {
106111
if (!(event.target instanceof HTMLElement)) return;
107112
const area = workspaceArea(event.target);
108113
if (!area?.dataset.workspaceArea) return;
109-
if (arrived && event.target === area && area.matches(":focus-visible")) {
110-
keyboardArea = area;
111-
area.setAttribute("data-workspace-keyboard-focus", "");
112-
}
114+
if (arrived && event.target === area) markKeyboardArea(area);
113115
lastArea = area.dataset.workspaceArea;
114116
const key = area.dataset.workspaceFocusKey ?? lastArea;
115117
lastFocused.delete(key);
@@ -178,6 +180,8 @@ export function createWorkspaceFocusController(doc: Document) {
178180
const active = root instanceof ShadowRoot ? root.activeElement : doc.activeElement;
179181
if (active === target || (active && target.contains(active))) {
180182
if (target !== area && !isConversation) revealInScrollers(target);
183+
// Focusing the already focused area fires no focusin, as when F6 has nowhere else to go.
184+
if (target === area) markKeyboardArea(area);
181185
return true;
182186
}
183187
}

0 commit comments

Comments
 (0)