diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts index be2bf019d8..316828a7aa 100644 --- a/apps/desktop/electron/main.ts +++ b/apps/desktop/electron/main.ts @@ -6138,11 +6138,11 @@ function buildApplicationMenu() { // whole shell) and a focused in-app browser needs ⌘R to mean "reload // this page", the way it does in every other browser. ⇧⌘R // (`forceReload`) below stays the unconditional escape hatch. - { - accelerator: 'CommandOrControl+R', - label: 'Reload', - click: () => sendPreviewNavCommand('reload') - }, + // + // No accelerator: ⌘R is claimed in `installPreviewShortcut`, which works + // on every platform (this menu exists only on macOS). Declaring it here + // too would fire the item and the input hook for one keypress. + { click: () => sendPreviewNavCommand('reload'), label: 'Reload' }, { role: 'forceReload' }, { label: 'Toggle Developer Tools', @@ -6241,17 +6241,28 @@ function installDevToolsShortcut(window) { function installPreviewShortcut(window) { window.webContents.on('before-input-event', (event, input) => { const key = String(input.key || '').toLowerCase() - const isCloseTabShortcut = key === 'w' && (IS_MAC ? input.meta : input.control) && !input.alt && !input.shift + const accel = (IS_MAC ? input.meta : input.control) && !input.alt + const isCloseTabShortcut = key === 'w' && accel && !input.shift // Always claim ⌘W here (the File>Close item deliberately has no // accelerator, so nothing else does). The renderer decides tab-vs-window // — no `previewShortcutActive` gate, so it works for every closeable tab. - if (!isCloseTabShortcut) { + if (isCloseTabShortcut) { + event.preventDefault() + sendClosePreviewRequested() + return } - event.preventDefault() - sendClosePreviewRequested() + // ⌘R rides here rather than on the View menu item for the same reason: + // the application menu only exists on macOS (it is set to null elsewhere, + // see #77845), so a menu accelerator would leave Windows and Linux with no + // way to reload a page at all. ⇧⌘R is left alone — that is `forceReload`, + // the unconditional whole-window escape hatch. + if (key === 'r' && accel && !input.shift) { + event.preventDefault() + sendPreviewNavCommand('reload') + } }) }