Skip to content

Commit 6f4fa09

Browse files
committed
fix: streamline menu handling and improve submenu assignment logic in MenuBar
1 parent b626272 commit 6f4fa09

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

src/menubar/index.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ export class MenuBar extends Disposable {
11541154

11551155
private onMenuTriggered(menuIndex: number, clicked: boolean) {
11561156
const menu = this.menus[menuIndex]
1157-
if (menuIndex !== MenuBar.OVERFLOW_INDEX && !menu?.submenu) {
1157+
if (menuIndex !== MenuBar.OVERFLOW_INDEX && !menu?.submenu) {
11581158
ipcRenderer.send(IpcChannels.MENU_EVENT, menu.commandId)
11591159
return
11601160
}
@@ -1356,22 +1356,30 @@ export class MenuBar extends Disposable {
13561356
>,
13571357
fromIndex: number
13581358
): void {
1359-
const hiddenMenus = showableMenus
1360-
.slice(fromIndex)
1361-
.filter((menu) => !!menu.submenu)
1359+
const hiddenMenus = showableMenus.slice(fromIndex)
13621360

13631361
if (!hiddenMenus.length) {
13641362
this.overflowMenu.submenu = undefined
13651363
return
13661364
}
13671365

13681366
this.overflowMenu.submenu = {
1369-
items: hiddenMenus.map((menu) => ({
1370-
...menu,
1371-
label: cleanMnemonic(menu.label),
1372-
submenu: menu.submenu,
1373-
type: 'submenu'
1374-
}))
1367+
items: hiddenMenus.map((menu) => {
1368+
if (!menu.submenu) {
1369+
return {
1370+
...menu,
1371+
label: cleanMnemonic(menu.label),
1372+
type: menu.type
1373+
}
1374+
}
1375+
1376+
return {
1377+
...menu,
1378+
label: cleanMnemonic(menu.label),
1379+
submenu: menu.submenu,
1380+
type: 'submenu'
1381+
}
1382+
})
13751383
} as any
13761384
}
13771385
}

0 commit comments

Comments
 (0)