From 4d1cdf83c989ca73133fa6a984bb0dc05e9524a6 Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Tue, 18 Aug 2026 06:11:51 -0500 Subject: [PATCH] fix(desktop): claim Cmd/Ctrl+R in before-input-event so it works off macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The application menu is only installed on macOS (#77845) — everywhere else it is set to null, which strips the role accelerators with it. A menu-only Cmd+R meant Windows and Linux got no page reload at all. Moves the claim into the same before-input-event hook Cmd+W already uses for exactly this reason, and drops the accelerator from the menu item so one keypress can't fire both paths on macOS. --- apps/desktop/electron/main.ts | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) 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') + } }) }