Skip to content

Commit eb206c6

Browse files
haydenkzclaude
andcommitted
fix(web): returning to the window no longer pulls focus from the device screen
Window refocus moves focus to the composer unless the focused element is a text field, preview, terminal, dialog, or popup. The device screen is a focusable role="application" element that forwards keys to the device, so coming back to the window took focus from it. Leave focus alone inside [role="application"], the same as type-to-focus now does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 5b72531 commit eb206c6

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎apps/web/src/components/ChatView.logic.test.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,6 +1845,12 @@ describe("shouldRefocusComposerOnWindowFocus", () => {
18451845
expect(shouldRefocusComposerOnWindowFocus(element(tagName))).toBe(false);
18461846
});
18471847

1848+
it("leaves a focused device screen alone", () => {
1849+
expect(shouldRefocusComposerOnWindowFocus(element("DIV", { within: "application" }))).toBe(
1850+
false,
1851+
);
1852+
});
1853+
18481854
it("leaves a focused terminal alone in the drawer and the right panel", () => {
18491855
expect(
18501856
shouldRefocusComposerOnWindowFocus(element("BUTTON", { within: "data-terminal-owner" })),

‎apps/web/src/components/ChatView.logic.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ export function shouldRefocusComposerOnWindowFocus(
12451245
}
12461246
return (
12471247
activeElement.closest(
1248-
'[role="dialog"], [role="alertdialog"], [data-slot$="-popup"], [data-terminal-owner]',
1248+
'[role="dialog"], [role="alertdialog"], [data-slot$="-popup"], [data-terminal-owner], [role="application"]',
12491249
) === null
12501250
);
12511251
}

0 commit comments

Comments
 (0)