Skip to content

Commit

Permalink
Merge pull request #8878 from brave/fix_sidebar_show_options
Browse files Browse the repository at this point in the history
Fixed sidebar show option is not applied properly when it's changed
  • Loading branch information
simonhong authored May 20, 2021
2 parents 25de8bc + 5d164c4 commit ddaa9d3
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions browser/ui/views/sidebar/sidebar_container_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,27 @@ bool SidebarContainerView::ShouldShowSidebar() const {
}

void SidebarContainerView::OnMouseEntered(const ui::MouseEvent& event) {
const auto show_option = GetSidebarService(browser_)->GetSidebarShowOption();
const bool autohide_sidebar =
show_option == ShowSidebarOption::kShowOnMouseOver ||
show_option == ShowSidebarOption::kShowOnClick;

// When user select to non-autohide option like "Never" option,
// hide timer is scheduled but this view can get mouse event when context
// menu is hidden. In this case, this should not be cancelled.
if (!autohide_sidebar)
return;

// Cancel hide schedule when mouse entered again quickly.
if (sidebar_hide_timer_.IsRunning())
sidebar_hide_timer_.Stop();
sidebar_hide_timer_.Stop();
}

void SidebarContainerView::OnMouseExited(const ui::MouseEvent& event) {
// When context menu is shown, this view can get this exited callback.
// In that case, ignore this callback because mouse is still in this view.
if (IsMouseHovered())
return;

const auto show_option = GetSidebarService(browser_)->GetSidebarShowOption();
const bool autohide_sidebar =
show_option == ShowSidebarOption::kShowOnMouseOver ||
Expand Down

0 comments on commit ddaa9d3

Please sign in to comment.