Skip to content

Commit 26bf5a7

Browse files
fix(desktop): a focused iframe keeps its own find shortcut
The host no longer claims mod+f when a subframe has focus, so pages whose keyboard target is an iframe (Google Docs, Sheets) keep their own find. Browser find stays reachable from the menu and command palette there. AI-assisted; verified with the tests and tools listed above.
1 parent f4b0ad6 commit 26bf5a7

2 files changed

Lines changed: 7 additions & 15 deletions

File tree

‎apps/desktop/src/preview/Manager.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ describe("PreviewManager", () => {
818818
["linux", false],
819819
["win32", false],
820820
] as const)(
821-
"lets the page claim the find shortcut before the host opens find on %s",
821+
"lets the page and its iframes claim the find shortcut before the host opens find on %s",
822822
([platform, usesMeta]) =>
823823
withManager(
824824
(manager) =>
@@ -878,8 +878,8 @@ describe("PreviewManager", () => {
878878
{ preventDefault } as never,
879879
{ ...findKey, shift: false, alt: false } as never,
880880
);
881-
expect(preventDefault).toHaveBeenCalledOnce();
882-
expect(send).toHaveBeenCalledTimes(2);
881+
expect(preventDefault).not.toHaveBeenCalled();
882+
expect(send).toHaveBeenCalledOnce();
883883

884884
Object.assign(preview.webContents, { focusedFrame: mainFrame });
885885
yield* manager.setForwardedShortcuts([
@@ -896,7 +896,7 @@ describe("PreviewManager", () => {
896896
altKey: true,
897897
},
898898
);
899-
expect(send).toHaveBeenCalledTimes(usesMeta ? 3 : 2);
899+
expect(send).toHaveBeenCalledTimes(usesMeta ? 2 : 1);
900900
}),
901901
platform,
902902
),

‎apps/desktop/src/preview/Manager.ts‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,16 +1506,6 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
15061506
hostPlatform === "darwin" ? "MacIntel" : hostPlatform,
15071507
),
15081508
);
1509-
// The guest preload runs only in the main frame, so only there can it report
1510-
// a key the page left unhandled.
1511-
const mainFrameHoldsFocus = (contents: Electron.WebContents) => {
1512-
const focused = contents.focusedFrame;
1513-
return (
1514-
focused !== null &&
1515-
focused.processId === contents.mainFrame.processId &&
1516-
focused.routingId === contents.mainFrame.routingId
1517-
);
1518-
};
15191509
const beforeInput = (event: Electron.Event, input: Electron.Input): void => {
15201510
syncMenuShortcuts(wc, input);
15211511
const host = wc.hostWebContents;
@@ -1534,7 +1524,9 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
15341524
altKey: input.alt,
15351525
});
15361526
if (forwarded && host) {
1537-
if (PAGE_FIRST_FORWARDED_COMMANDS.has(forwarded.command) && mainFrameHoldsFocus(wc)) return;
1527+
// The page keeps these keys. Only the main-frame preload can report one it
1528+
// left unhandled, so a focused iframe (e.g. Google Docs' input) keeps its own find.
1529+
if (PAGE_FIRST_FORWARDED_COMMANDS.has(forwarded.command)) return;
15381530
event.preventDefault();
15391531
if (!input.isAutoRepeat) {
15401532
if (

0 commit comments

Comments
 (0)