Skip to content

Commit 3343303

Browse files
authored
fix(desktop): bind Cmd+W to close the window (#1174)
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 d5ba68f commit 3343303

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
@@ -853,9 +853,18 @@ const installApplicationMenu = () => {
853853
{ role: "quit" },
854854
],
855855
};
856+
// The close-window accelerator (Cmd+W on macOS, Ctrl+W elsewhere) lives on
857+
// the `close` role, which the File menu carries. The Window menu's role only
858+
// provides Minimize/Zoom/Front, so without an explicit File menu nothing
859+
// binds Cmd+W and the window can't be closed from the keyboard.
860+
const fileMenu: MenuItemConstructorOptions = {
861+
label: "File",
862+
submenu: [{ role: "close" }],
863+
};
856864
Menu.setApplicationMenu(
857865
Menu.buildFromTemplate([
858866
appMenu,
867+
fileMenu,
859868
{ role: "editMenu" },
860869
{ role: "viewMenu" },
861870
{ role: "windowMenu" },

0 commit comments

Comments
 (0)