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 May 25, 2021
1 parent b2e36f5 commit a40396d
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,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 a40396d

Please sign in to comment.