Commit 1d73b862 authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros: Reset the AppListView focus when it is reshown

When the top window is deactivated, the AppListView is shown without
any preparation. Fix this by resetting the focus and switching to the
first page.

Bug: 951586
Change-Id: I4a39dc503cf6cbee32cf60d29026eac10f3dc84d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1576142
Auto-Submit: Alex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#653651}
parent cf5d5d82
...@@ -386,6 +386,7 @@ void AppListPresenterImpl::OnWindowFocused(aura::Window* gained_focus, ...@@ -386,6 +386,7 @@ void AppListPresenterImpl::OnWindowFocused(aura::Window* gained_focus,
HandleCloseOpenSearchBox(); HandleCloseOpenSearchBox();
} else if (applist_window->Contains(gained_focus)) { } else if (applist_window->Contains(gained_focus)) {
home_launcher_shown_ = true; home_launcher_shown_ = true;
view_->ResetForShow();
} }
} }
......
...@@ -452,6 +452,16 @@ void AppListView::Dismiss() { ...@@ -452,6 +452,16 @@ void AppListView::Dismiss() {
GetWidget()->Deactivate(); GetWidget()->Deactivate();
} }
void AppListView::ResetForShow() {
if (GetFocusManager()->GetFocusedView() != GetInitiallyFocusedView())
GetInitiallyFocusedView()->RequestFocus();
if (GetAppsPaginationModel()->total_pages() > 0 &&
GetAppsPaginationModel()->selected_page() != 0) {
GetAppsPaginationModel()->SelectPage(0, false /* animate */);
}
}
void AppListView::CloseOpenedPage() { void AppListView::CloseOpenedPage() {
if (HandleCloseOpenFolder()) if (HandleCloseOpenFolder())
return; return;
......
...@@ -150,6 +150,9 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView, ...@@ -150,6 +150,9 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
// Dismisses the UI, cleans up and sets the state to CLOSED. // Dismisses the UI, cleans up and sets the state to CLOSED.
void Dismiss(); void Dismiss();
// Resets the child views before showing the AppListView.
void ResetForShow();
// Closes opened folder or search result page if they are opened. // Closes opened folder or search result page if they are opened.
void CloseOpenedPage(); void CloseOpenedPage();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment