fix(desktop): close the window with ⇧⌘W so ⌘W never closes it (#57150)

This commit is contained in:
Kit Langton
2026-10-19 13:22:28 -07:00
committed by GitHub
Unverified
parent 879479b467
commit 3d9fec7f8c
3 changed files with 20 additions and 2 deletions
@@ -120,7 +120,13 @@ export const DESKTOP_MENU: DesktopMenu[] = [
accelerator: { macos: "Cmd+Shift+N", windows: "Ctrl+Shift+N" },
},
{ type: "separator" },
{ type: "item", labelKey: "desktop.menu.closeWindow", action: "window.close", role: "close" },
{
type: "item",
labelKey: "desktop.menu.closeWindow",
action: "window.close",
role: "close",
accelerator: { macos: "Shift+Cmd+W", windows: "Ctrl+Shift+W" },
},
],
},
{
@@ -8,6 +8,13 @@ test("resolves the new window accelerator only with its modifiers", () => {
expect(windowsMenuAccelerator(new KeyboardEvent("keydown", { key: "N" }))).toBeUndefined()
})
test("resolves Ctrl+Shift+W to close the window and leaves Ctrl+W to tabs", () => {
expect(windowsMenuAccelerator(new KeyboardEvent("keydown", { key: "W", ctrlKey: true, shiftKey: true }))).toBe(
"window.close",
)
expect(windowsMenuAccelerator(new KeyboardEvent("keydown", { key: "w", ctrlKey: true }))).toBeUndefined()
})
test.each(["v", "c", "x", "a", "A", "z", "y"])("leaves Ctrl+%s to the focused editor", (key) => {
expect(windowsMenuAccelerator(new KeyboardEvent("keydown", { key, ctrlKey: true }))).toBeUndefined()
})
+6 -1
View File
@@ -109,7 +109,12 @@ function nativeMenu(menu: DesktopMenu, extra: readonly MenubarEntry[], deps: Dep
function nativeItem(entry: DesktopMenuEntry, deps: Deps): MenuItemConstructorOptions {
if (entry.type === "separator") return { type: "separator" }
if (entry.role) return { role: nativeRole(entry.role), label: entry.labelKey ? nativeT(entry.labelKey) : undefined }
if (entry.role)
return {
role: nativeRole(entry.role),
label: entry.labelKey ? nativeT(entry.labelKey) : undefined,
accelerator: entry.accelerator?.macos,
}
const item: MenuItemConstructorOptions = {
label: entry.labelKey ? nativeT(entry.labelKey) : undefined,