diff --git a/apps/web/src/components/ChatView.logic.test.ts b/apps/web/src/components/ChatView.logic.test.ts index 2b9a18cb90fb7d49d82e794de80216deb3acafd1..be279f220e7e0cb36da23e807bb07d8004f0c273 100644 --- a/apps/web/src/components/ChatView.logic.test.ts +++ b/apps/web/src/components/ChatView.logic.test.ts @@ -2180,6 +2180,10 @@ describe("shouldRefocusComposerOnWindowFocus", () => { expect(shouldRefocusComposerOnWindowFocus(element("DIV", { role: "textbox" }))).toBe(false); }); + it.each(["IFRAME", "WEBVIEW"])("leaves a focused %s preview alone", (tagName) => { + expect(shouldRefocusComposerOnWindowFocus(element(tagName))).toBe(false); + }); + it("leaves a focused terminal alone in the drawer and the right panel", () => { expect( shouldRefocusComposerOnWindowFocus(element("BUTTON", { within: "data-terminal-owner" })), diff --git a/apps/web/src/components/ChatView.logic.ts b/apps/web/src/components/ChatView.logic.ts index 2707050070e921cbd8ec213e6abd8e9e8f3db8ef..ed1422a71109c95a678c0e0be697936b84a38956 100644 --- a/apps/web/src/components/ChatView.logic.ts +++ b/apps/web/src/components/ChatView.logic.ts @@ -1350,6 +1350,8 @@ export function shouldRefocusComposerOnWindowFocus( activeElement.tagName === "INPUT" || activeElement.tagName === "TEXTAREA" || activeElement.tagName === "SELECT" || + activeElement.tagName === "IFRAME" || + activeElement.tagName === "WEBVIEW" || activeElement.isContentEditable === true || activeElement.getAttribute("role") === "textbox" ) {