mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-10-23 03:31:56 +00:00
context-menu: Remove trailing and leading separators when not required.
Fixes: #979.
This commit is contained in:
@@ -22,7 +22,8 @@ export const contextMenu = (webContents: Electron.WebContents, event: Event, pro
|
||||
webContents.session.addWordToSpellCheckerDictionary(props.misspelledWord);
|
||||
}
|
||||
}, {
|
||||
type: 'separator'
|
||||
type: 'separator',
|
||||
visible: props.isEditable && isText && props.misspelledWord.length !== 0
|
||||
}, {
|
||||
label: `${t.__('Look Up')} "${props.selectionText}"`,
|
||||
visible: process.platform === 'darwin' && isText,
|
||||
@@ -30,7 +31,8 @@ export const contextMenu = (webContents: Electron.WebContents, event: Event, pro
|
||||
webContents.showDefinitionForSelection();
|
||||
}
|
||||
}, {
|
||||
type: 'separator'
|
||||
type: 'separator',
|
||||
visible: process.platform === 'darwin' && isText
|
||||
}, {
|
||||
label: t.__('Cut'),
|
||||
visible: isText,
|
||||
@@ -80,7 +82,8 @@ export const contextMenu = (webContents: Electron.WebContents, event: Event, pro
|
||||
});
|
||||
}
|
||||
}, {
|
||||
type: 'separator'
|
||||
type: 'separator',
|
||||
visible: isLink || props.mediaType === 'image'
|
||||
}, {
|
||||
label: t.__('Services'),
|
||||
visible: process.platform === 'darwin',
|
||||
@@ -98,7 +101,13 @@ export const contextMenu = (webContents: Electron.WebContents, event: Event, pro
|
||||
});
|
||||
}
|
||||
}
|
||||
// Hide the invisible separators on Linux and Windows
|
||||
// Electron has a bug which ignores visible: false parameter for separator menuitems. So we remove them here.
|
||||
// https://github.com/electron/electron/issues/5869
|
||||
// https://github.com/electron/electron/issues/6906
|
||||
|
||||
const menu = Menu.buildFromTemplate(menuTemplate);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-boolean-literal-compare
|
||||
const filteredMenuTemplate = menuTemplate.filter(menuItem => menuItem.visible !== false);
|
||||
const menu = Menu.buildFromTemplate(filteredMenuTemplate);
|
||||
menu.popup();
|
||||
};
|
||||
|
Reference in New Issue
Block a user