Commit 673db747 authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

cros: Avoid visible flash when the AppListView is refocused

We call ClearSearch when the AppListView gains focus in tablet mode.
This is one of many things we do to reset the AppListView when the it
(which is always open) is focused as the last open window is closed.

The issue is that ClearSearch actually refreshes the suggestion chips
(causing the visible flash). This refresh is unnecessary because the
chips are already refreshed after an app is launched.

Bug: 979594
Change-Id: I8baec08c78fc8c5439127427de62fddeddfb414c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1690723
Commit-Queue: Alex Newcomer <newcomer@chromium.org>
Reviewed-by: default avatarTao Wu <wutao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676161}
parent fb20eed1
...@@ -85,9 +85,6 @@ void AppListMainView::AddContentsViews() { ...@@ -85,9 +85,6 @@ void AppListMainView::AddContentsViews() {
AddChildView(contents_view_); AddChildView(contents_view_);
search_box_view_->set_contents_view(contents_view_); search_box_view_->set_contents_view(contents_view_);
// Clear the old query and start search.
search_box_view_->ClearSearch();
} }
void AppListMainView::ShowAppListWhenReady() { void AppListMainView::ShowAppListWhenReady() {
......
...@@ -137,6 +137,9 @@ void ContentsView::Init(AppListModel* model) { ...@@ -137,6 +137,9 @@ void ContentsView::Init(AppListModel* model) {
GetAppsContainerView()->UpdateSuggestionChips(); GetAppsContainerView()->UpdateSuggestionChips();
ActivePageChanged(); ActivePageChanged();
// Hide the search results initially.
ShowSearchResults(false);
} }
void ContentsView::ResetForShow() { void ContentsView::ResetForShow() {
......
...@@ -450,6 +450,10 @@ bool SearchBoxViewBase::IsSearchBoxTrimmedQueryEmpty() const { ...@@ -450,6 +450,10 @@ bool SearchBoxViewBase::IsSearchBoxTrimmedQueryEmpty() const {
} }
void SearchBoxViewBase::ClearSearch() { void SearchBoxViewBase::ClearSearch() {
// Avoid setting |search_box_| text to empty if it is already empty.
if (search_box_->text() == base::string16())
return;
search_box_->SetText(base::string16()); search_box_->SetText(base::string16());
UpdateButtonsVisisbility(); UpdateButtonsVisisbility();
// Updates model and fires query changed manually because SetText() above // Updates model and fires query changed manually because SetText() above
......
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