Skip to content

Commit 41728e3

Browse files
saphidclaude
authored andcommitted
fix(desktop): Ctrl+R on macOS reaches the preview page instead of reloading it
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 61c3794 commit 41728e3

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,33 @@ describe("PreviewManager", () => {
615615
),
616616
);
617617

618+
effectIt.effect.each([
619+
["darwin", true, false, true],
620+
["darwin", false, true, false],
621+
["linux", false, true, true],
622+
["win32", true, false, false],
623+
] as const)(
624+
"reloads the preview only on the platform refresh chord: %s meta=%s ctrl=%s",
625+
([platform, meta, control, expected]) =>
626+
withManager(
627+
(manager) =>
628+
Effect.gen(function* () {
629+
const preview = makeFaviconWebContents();
630+
fromId.mockReturnValue(preview.webContents);
631+
yield* manager.createTab("tab_refresh");
632+
yield* manager.registerWebview("tab_refresh", 42);
633+
const preventDefault = vi.fn();
634+
preview.listeners.get("before-input-event")!(
635+
{ preventDefault } as never,
636+
{ type: "keyDown", key: "r", meta, control, shift: false, alt: false } as never,
637+
);
638+
expect(preventDefault).toHaveBeenCalledTimes(expected ? 1 : 0);
639+
expect(preview.reload).toHaveBeenCalledTimes(expected ? 1 : 0);
640+
}),
641+
platform,
642+
),
643+
);
644+
618645
effectIt.effect("keeps editing and forwarded shortcuts in whichever tab holds focus", () =>
619646
withManager((manager) =>
620647
Effect.gen(function* () {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,10 @@ export const previewWindowOpenAction = (details: {
464464
: "navigate";
465465
};
466466

467-
const isPreviewRefreshShortcut = (input: Electron.Input): boolean =>
467+
const isPreviewRefreshShortcut = (input: Electron.Input, platform: NodeJS.Platform): boolean =>
468468
input.type === "keyDown" &&
469469
input.key.toLowerCase() === "r" &&
470-
(input.meta || input.control) &&
470+
(platform === "darwin" ? input.meta && !input.control : input.control && !input.meta) &&
471471
!input.shift &&
472472
!input.alt;
473473

@@ -1488,7 +1488,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
14881488
}
14891489
return;
14901490
}
1491-
if (isPreviewRefreshShortcut(input)) {
1491+
if (isPreviewRefreshShortcut(input, hostPlatform)) {
14921492
event.preventDefault();
14931493
runFork(
14941494
attempt({ operation: "shortcut.refresh", tabId, webContentsId: wc.id }, () =>

0 commit comments

Comments
 (0)