Skip to content

Commit

Permalink
Remove duplicated menu separator after remove translate menu item
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyBarabash committed Jun 9, 2021
1 parent 1e48647 commit 6d4a593
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,20 @@ void BraveRenderViewContextMenu::InitMenu() {
// Only show the translate item when go-translate is enabled.
#if !BUILDFLAG(ENABLE_BRAVE_TRANSLATE_GO)
index = menu_model_.GetIndexOfCommandId(IDC_CONTENT_CONTEXT_TRANSLATE);
if (index != -1)
if (index != -1) {
menu_model_.RemoveItemAt(index);

// Separator always precedes translate item,
// see RenderViewContextMenu::AppendPageItems.
// Remove separator if it is duplicated by any reason.
if (index < menu_model_.GetItemCount() &&
menu_model_.GetTypeAt(index) ==
ui::MenuModel::ItemType::TYPE_SEPARATOR &&
index > 0 &&
menu_model_.GetTypeAt(index - 1) ==
ui::MenuModel::ItemType::TYPE_SEPARATOR) {
menu_model_.RemoveItemAt(index);
}
}
#endif
}

0 comments on commit 6d4a593

Please sign in to comment.