Skip to content

Commit 9984295

Browse files
fix(desktop): let the page handle zoom chords before the browser panel zooms
Forwarded zoom chords were desktop-first, so the guest page never saw Cmd/Ctrl+=, - or 0 and canvas apps lost their own zoom. Route them through the page-first path used for find: the panel zooms only when the page leaves the key unhandled. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 33369eb commit 9984295

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ describe("PreviewManager", () => {
820820
["linux", false],
821821
["win32", false],
822822
] as const)(
823-
"lets the page and its iframes claim the find shortcut before the host opens find on %s",
823+
"lets the page and its iframes claim the find and zoom shortcuts before the host acts on %s",
824824
([platform, usesMeta]) =>
825825
withManager(
826826
(manager) =>
@@ -838,8 +838,23 @@ describe("PreviewManager", () => {
838838
yield* manager.registerWebview("tab_page_find", 42);
839839
yield* manager.setForwardedShortcuts([
840840
{ command: "preview.find", shortcut: parseKeybindingShortcut("mod+f")! },
841+
{ command: "preview.zoomIn", shortcut: parseKeybindingShortcut("mod+=")! },
841842
]);
842843
const beforeInput = preview.listeners.get("before-input-event")!;
844+
const keepsZoom = vi.fn();
845+
beforeInput(
846+
{ preventDefault: keepsZoom } as never,
847+
{
848+
type: "keyDown",
849+
key: "=",
850+
code: "Equal",
851+
meta: usesMeta,
852+
control: !usesMeta,
853+
shift: false,
854+
alt: false,
855+
} as never,
856+
);
857+
expect(keepsZoom).not.toHaveBeenCalled();
843858
const findKey = {
844859
type: "keyDown",
845860
key: "f",

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,9 @@ type FindResultListener = (event: DesktopPreviewFindResultEvent) => Effect.Effec
444444

445445
const PAGE_FIRST_FORWARDED_COMMANDS: ReadonlySet<PreviewForwardedShortcut["command"]> = new Set([
446446
"preview.find",
447+
"preview.zoomIn",
448+
"preview.zoomOut",
449+
"preview.resetZoom",
447450
]);
448451

449452
const decodePageShortcutKeys = Schema.decodeUnknownOption(
@@ -1553,7 +1556,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
15531556
});
15541557
if (forwarded && host) {
15551558
// The page keeps these keys. Only the main-frame preload can report one it
1556-
// left unhandled, so a focused iframe (e.g. Google Docs' input) keeps its own find.
1559+
// left unhandled, so a focused iframe (e.g. Google Docs' input) keeps its own find or zoom.
15571560
if (PAGE_FIRST_FORWARDED_COMMANDS.has(forwarded.command)) return;
15581561
event.preventDefault();
15591562
if (!input.isAutoRepeat) {

0 commit comments

Comments
 (0)