Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed empty space is added in guest window's app menu (uplift to 1.74.x) #26974

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions browser/ui/toolbar/brave_app_menu_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,21 @@ void BraveAppMenuModel::BuildBraveProductsSection() {

#if defined(TOOLKIT_VIEWS)
if (sidebar::CanUseSidebar(browser())) {
auto index = GetNextIndexOfBraveProductsSection();
// Remove above separator as sidebar will add its top & bottom
// separator.
// If |need_separator| is false, there is no item after window section
// entry and separator. In this case, need to remove that separator because
// we will add different type of separators around sidebar menu entry.
if (!need_separator) {
RemoveItemAt(index - 1);
index--;
}

// Don't need finish this section with more separator as
// we'll add another separators around sidebar menu entry below.
need_separator = false;

sidebar_show_option_model_ = std::make_unique<ui::ButtonMenuItemModel>(
IDS_APP_MENU_SIDEBAR_TITLE, this);

Expand All @@ -182,16 +197,16 @@ void BraveAppMenuModel::BuildBraveProductsSection() {
IDC_SIDEBAR_SHOW_OPTION_MOUSEOVER, IDS_APP_MENU_SIDEBAR_HOVER);
sidebar_show_option_model_->AddGroupItemWithStringId(
IDC_SIDEBAR_SHOW_OPTION_NEVER, IDS_APP_MENU_SIDEBAR_OFF);
const auto index = GetNextIndexOfBraveProductsSection();

// Add additional spacing because LOWER|UPPER separator has more narrow
// spacing then normal separator.
InsertSeparatorAt(index++, ui::SPACING_SEPARATOR);
InsertSeparatorAt(index++, ui::LOWER_SEPARATOR);
AddButtonItemAt(IDC_SIDEBAR_SHOW_OPTION_MENU,
sidebar_show_option_model_.get(),
static_cast<size_t>(index));
// Insert separator to the top and bottom
InsertSeparatorAt(index, ui::LOWER_SEPARATOR);
InsertSeparatorAt(index + 2, ui::UPPER_SEPARATOR);

// Already added separator.
need_separator = false;
static_cast<size_t>(index++));
InsertSeparatorAt(index++, ui::UPPER_SEPARATOR);
InsertSeparatorAt(index, ui::SPACING_SEPARATOR);
}
#endif
if (need_separator) {
Expand Down
Loading