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

Remove duplicated menu separator after remove translate menu item #8914

Merged
merged 1 commit into from
Jun 17, 2021

Conversation

AlexeyBarabash
Copy link
Contributor

@AlexeyBarabash AlexeyBarabash commented May 24, 2021

Resolves brave/brave-browser#15714

Sometimes after removing the Translate menu item, separator item is duplicated.
This PR removes the duplicated separator, if required.

Not related to the sync options on Nightly 1.27.4 at least.

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

  1. Open the website of other language than your system has
  2. Invoke the context menu
  3. Ensure there are no double separators one by one, as on Double separator line when you can "send to Google phone" brave-browser#15714 screenshots.

@AlexeyBarabash AlexeyBarabash requested a review from a team as a code owner May 24, 2021 14:21
@AlexeyBarabash AlexeyBarabash requested a review from yrliou May 24, 2021 14:29
menu_model_.RemoveItemAt(index);

// Separator always precedes translate item,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@AlexeyBarabash AlexeyBarabash May 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bridiver ,
42c0333
yes, there are two useful methods: RenderViewContextMenuBase::RemoveSeparatorBeforeMenuItem and RenderViewContextMenuBase::RemoveAdjacentSeparators.

RemoveAdjacentSeparators may be used in the end of BraveRenderViewContextMenu::InitMenu() to exclude any possibility of duplicating the separators.

Both RemoveSeparatorBeforeMenuItem and RemoveAdjacentSeparators have the code in the end

  if (toolkit_delegate_)
    toolkit_delegate_->RebuildMenu();

But toolkit_delegate_ is initialized after BraveRenderViewContextMenu::InitMenu(), so I had to clear and restore toolkit_delegate_ to avoid the crash.

@AlexeyBarabash
Copy link
Contributor Author

CI failed, needs rebase

@AlexeyBarabash AlexeyBarabash force-pushed the duplicated_separator branch from f507f7b to 495556b Compare May 25, 2021 14:32
@AlexeyBarabash
Copy link
Contributor Author

CI failed on gn_check, related to the PR

@AlexeyBarabash AlexeyBarabash force-pushed the duplicated_separator branch 4 times, most recently from 27e5a48 to 42c0333 Compare May 31, 2021 14:37
@AlexeyBarabash AlexeyBarabash requested a review from bridiver June 1, 2021 11:07
@AlexeyBarabash AlexeyBarabash added the CI/skip Do not run CI builds (except noplatform) label Jun 9, 2021
@AlexeyBarabash AlexeyBarabash force-pushed the duplicated_separator branch from 42c0333 to d570210 Compare June 9, 2021 21:04
Copy link
Member

@yrliou yrliou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as long as we pass the test plan in #3103.

Copy link
Member

@yrliou yrliou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AlexeyBarabash AlexeyBarabash requested a review from a team as a code owner June 10, 2021 19:31
@AlexeyBarabash AlexeyBarabash requested a review from a team as a code owner June 15, 2021 18:48
fixes brave/brave-browser#15714

Override of RenderViewContextMenuViews::Show is used
@AlexeyBarabash AlexeyBarabash removed the CI/skip Do not run CI builds (except noplatform) label Jun 16, 2021
@AlexeyBarabash AlexeyBarabash merged commit 31981be into master Jun 17, 2021
@AlexeyBarabash AlexeyBarabash deleted the duplicated_separator branch June 17, 2021 09:54
@@ -161,6 +161,13 @@ source_set("ui") {
"views/toolbar/bookmark_button.h",
]

if (use_aura) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlexeyBarabash Can you check this condition again?
I think below views related sources should be included with toolkit_views condition above.
|use_aura| is false for macOS.

@AlexeyBarabash AlexeyBarabash added this to the 1.28.x - Nightly milestone Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Double separator line when you can "send to Google phone"
4 participants