From d5edadabe683004e5606276b878db614bc82ce12 Mon Sep 17 00:00:00 2001 From: pengx17 Date: Wed, 14 Aug 2024 04:14:16 +0000 Subject: [PATCH] fix(electron): cmd+num not working on mac (#7865) fix AF-1248 hidden menu group + acceleratorWorksWhenHidden does not work on mac --- .../src/main/application-menu/create.ts | 29 +++++++++---------- tests/affine-desktop/e2e/tabs.spec.ts | 4 ++- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/packages/frontend/electron/src/main/application-menu/create.ts b/packages/frontend/electron/src/main/application-menu/create.ts index 0120646f8a..016dac844c 100644 --- a/packages/frontend/electron/src/main/application-menu/create.ts +++ b/packages/frontend/electron/src/main/application-menu/create.ts @@ -139,22 +139,19 @@ export function createApplicationMenu() { undoCloseTab().catch(console.error); }, }, - { - label: 'Switch to tab', - acceleratorWorksWhenHidden: true, - visible: false, - submenu: [1, 2, 3, 4, 5, 6, 7, 8, 9].map(n => { - const shortcut = `CommandOrControl+${n}`; - const listener = () => { - switchTab(n); - }; - return { - label: `Switch to tab ${n}`, - accelerator: shortcut, - click: listener, - }; - }), - }, + ...[1, 2, 3, 4, 5, 6, 7, 8, 9].map(n => { + const shortcut = `CommandOrControl+${n}`; + const listener = () => { + switchTab(n); + }; + return { + acceleratorWorksWhenHidden: true, + label: `Switch to tab ${n}`, + accelerator: shortcut, + click: listener, + visible: false, + }; + }), ], }, { diff --git a/tests/affine-desktop/e2e/tabs.spec.ts b/tests/affine-desktop/e2e/tabs.spec.ts index 0d2b3f6864..e1a1c7a479 100644 --- a/tests/affine-desktop/e2e/tabs.spec.ts +++ b/tests/affine-desktop/e2e/tabs.spec.ts @@ -154,7 +154,9 @@ async function enableSplitView(page: Page) { }) ); }); - await page.reload(); + await page.reload({ + timeout: 30000, + }); } test('open new tab via cmd+click page link', async ({ page }) => {