Skip to content

Commit 85693f2

Browse files
committed
fix(desktop): bind Cmd+W to close the window
The application menu had no File menu, so the close-window role (which carries the Cmd+W / Ctrl+W accelerator) was never registered. The Window menu role only provides Minimize, Zoom, and Bring All to Front, so there was no keyboard shortcut to close the window. Add a File menu with the close role to restore the standard accelerator on every platform.
1 parent eb9ed89 commit 85693f2

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

apps/desktop/src/main/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,9 +846,18 @@ const installApplicationMenu = () => {
846846
{ role: "quit" },
847847
],
848848
};
849+
// The close-window accelerator (Cmd+W on macOS, Ctrl+W elsewhere) lives on
850+
// the `close` role, which the File menu carries. The Window menu's role only
851+
// provides Minimize/Zoom/Front, so without an explicit File menu nothing
852+
// binds Cmd+W and the window can't be closed from the keyboard.
853+
const fileMenu: MenuItemConstructorOptions = {
854+
label: "File",
855+
submenu: [{ role: "close" }],
856+
};
849857
Menu.setApplicationMenu(
850858
Menu.buildFromTemplate([
851859
appMenu,
860+
fileMenu,
852861
{ role: "editMenu" },
853862
{ role: "viewMenu" },
854863
{ role: "windowMenu" },

0 commit comments

Comments
 (0)