fix: order menu items before filtering excess separators (#25563)
This commit is contained in:
parent
a0b238a998
commit
3503d3745b
3 changed files with 44 additions and 15 deletions
|
@ -157,9 +157,12 @@ function sortGroups<T> (groups: {id?: T}[][]) {
|
|||
return sortedGroupIndexes.map(i => groups[i]);
|
||||
}
|
||||
|
||||
export function sortMenuItems (menuItems: {type?: string, id?: string}[]) {
|
||||
const isSeparator = (item: {type?: string}) => item.type === 'separator';
|
||||
const separators = menuItems.filter(i => i.type === 'separator');
|
||||
export function sortMenuItems (menuItems: (Electron.MenuItemConstructorOptions | Electron.MenuItem)[]) {
|
||||
const isSeparator = (i: Electron.MenuItemConstructorOptions | Electron.MenuItem) => {
|
||||
const opts = i as Electron.MenuItemConstructorOptions;
|
||||
return i.type === 'separator' && !opts.before && !opts.after && !opts.beforeGroupContaining && !opts.afterGroupContaining;
|
||||
};
|
||||
const separators = menuItems.filter(isSeparator);
|
||||
|
||||
// Split the items into their implicit groups based upon separators.
|
||||
const groups = splitArray(menuItems, isSeparator);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue