From 0f7c39dc7c0352aa557f4e17f153e2a7af811c36 Mon Sep 17 00:00:00 2001 From: Brian Clifton Date: Fri, 2 Sep 2016 14:38:25 -0700 Subject: [PATCH] Remove extra separator menu item (doesn't show on Mac) Fixes https://github.com/brave/browser-laptop/issues/3666 Auditors: @charbelrami @srirambv Test Plan: - With new code in place, launch Brave on Windows - Delete all your bookmarks - Confirm bookmarks menu looks good (no extra separator) - Go to google.com - Right click the "Google Search" button - Confirm you don't see the extra separator --- app/browser/menu.js | 15 +++++++++++---- js/contextMenus.js | 6 +++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/browser/menu.js b/app/browser/menu.js index 8d6b175de57..4101c0e060d 100644 --- a/app/browser/menu.js +++ b/app/browser/menu.js @@ -364,7 +364,7 @@ const createHistorySubmenu = (CommonMenu) => { } const createBookmarksSubmenu = (CommonMenu) => { - return [ + let submenu = [ { label: locale.translation('bookmarkPage'), type: 'checkbox', @@ -386,9 +386,16 @@ const createBookmarksSubmenu = (CommonMenu) => { CommonMenu.bookmarksManagerMenuItem(), CommonMenu.bookmarksToolbarMenuItem(), CommonMenu.separatorMenuItem, - CommonMenu.importBookmarksMenuItem(), - CommonMenu.separatorMenuItem - ].concat(menuUtil.createBookmarkMenuItems()) + CommonMenu.importBookmarksMenuItem() + ] + + const bookmarks = menuUtil.createBookmarkMenuItems() + if (bookmarks.length > 0) { + submenu.push(CommonMenu.separatorMenuItem) + submenu = submenu.concat(bookmarks) + } + + return submenu } const createWindowSubmenu = (CommonMenu) => { diff --git a/js/contextMenus.js b/js/contextMenus.js index 01415effc16..be0e4fc5de7 100644 --- a/js/contextMenus.js +++ b/js/contextMenus.js @@ -870,7 +870,11 @@ function mainTemplateInit (nodeProps, frame) { label: locale.translation('redo'), accelerator: 'Shift+CmdOrCtrl+Z', role: 'redo' - }, CommonMenu.separatorMenuItem, ...editableItems, CommonMenu.separatorMenuItem) + }, CommonMenu.separatorMenuItem) + + if (editableItems.length > 0) { + template.push(...editableItems, CommonMenu.separatorMenuItem) + } } else if (isTextSelected) { if (isDarwin) { template.push(showDefinitionMenuItem(nodeProps.selectionText),