Commit 26561a9d authored by chinsenj's avatar chinsenj Committed by Commit Bot

cros: Fix app folder name textfield selection.

If a user presses on a folder name textfield it selects the whole field.
If they press the left/right arrow keys it does nothing. Only after the
second left/right arrow key press does the textfield clears the
selection and shows the cursor.

This CL makes it so after the first left/right arrow key press the
textfield clears the selection and shows the cursor.

Bug: 1133681
Change-Id: I8c27ce850c05411f887bc8bf92f706485645c6c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2441999Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Jeremy Chinsen <chinsenj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812726}
parent a2bc162b
...@@ -310,6 +310,10 @@ void AppListPresenterDelegateImpl::OnKeyEvent(ui::KeyEvent* event) { ...@@ -310,6 +310,10 @@ void AppListPresenterDelegateImpl::OnKeyEvent(ui::KeyEvent* event) {
if (view_->IsShowingEmbeddedAssistantUI()) if (view_->IsShowingEmbeddedAssistantUI())
return; return;
// Don't absorb the first event when renaming folder.
if (view_->IsFolderBeingRenamed())
return;
// Arrow keys or Tab will engage the traversal mode. // Arrow keys or Tab will engage the traversal mode.
if ((IsUnhandledArrowKeyEvent(*event) || event->key_code() == ui::VKEY_TAB)) { if ((IsUnhandledArrowKeyEvent(*event) || event->key_code() == ui::VKEY_TAB)) {
// Handle the first arrow key event to just show the focus rings. // Handle the first arrow key event to just show the focus rings.
......
...@@ -845,6 +845,13 @@ bool AppListView::IsShowingEmbeddedAssistantUI() const { ...@@ -845,6 +845,13 @@ bool AppListView::IsShowingEmbeddedAssistantUI() const {
return app_list_main_view()->contents_view()->IsShowingEmbeddedAssistantUI(); return app_list_main_view()->contents_view()->IsShowingEmbeddedAssistantUI();
} }
bool AppListView::IsFolderBeingRenamed() {
return GetAppsContainerView()
->app_list_folder_view()
->folder_header_view()
->HasTextFocus();
}
void AppListView::UpdatePageResetTimer(bool app_list_visibility) { void AppListView::UpdatePageResetTimer(bool app_list_visibility) {
if (app_list_visibility || !delegate_->IsInTabletMode()) { if (app_list_visibility || !delegate_->IsInTabletMode()) {
page_reset_timer_.Stop(); page_reset_timer_.Stop();
...@@ -2127,14 +2134,10 @@ void AppListView::RedirectKeyEventToSearchBox(ui::KeyEvent* event) { ...@@ -2127,14 +2134,10 @@ void AppListView::RedirectKeyEventToSearchBox(ui::KeyEvent* event) {
views::Textfield* search_box = search_box_view_->search_box(); views::Textfield* search_box = search_box_view_->search_box();
const bool is_search_box_focused = search_box->HasFocus(); const bool is_search_box_focused = search_box->HasFocus();
const bool is_folder_header_view_focused = GetAppsContainerView()
->app_list_folder_view()
->folder_header_view()
->HasTextFocus();
// Do not redirect the key event to the |search_box_| when focus is on a // Do not redirect the key event to the |search_box_| when focus is on a
// text field. // text field.
if (is_search_box_focused || is_folder_header_view_focused) if (is_search_box_focused || IsFolderBeingRenamed())
return; return;
// Do not redirect the arrow keys in app list as they are are used for focus // Do not redirect the arrow keys in app list as they are are used for focus
......
...@@ -370,6 +370,9 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView, ...@@ -370,6 +370,9 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView,
// Returns true if the Embedded Assistant UI is currently being shown. // Returns true if the Embedded Assistant UI is currently being shown.
bool IsShowingEmbeddedAssistantUI() const; bool IsShowingEmbeddedAssistantUI() const;
// Returns true if a folder is being renamed.
bool IsFolderBeingRenamed();
// Starts or stops a timer which will reset the app list to the initial apps // Starts or stops a timer which will reset the app list to the initial apps
// page. Called when the app list's visibility changes. // page. Called when the app list's visibility changes.
void UpdatePageResetTimer(bool app_list_visibility); void UpdatePageResetTimer(bool app_list_visibility);
......
...@@ -119,6 +119,9 @@ class FolderHeaderView::FolderNameView : public views::Textfield, ...@@ -119,6 +119,9 @@ class FolderHeaderView::FolderNameView : public views::Textfield,
if (!DoesMouseEventActuallyIntersect(event)) if (!DoesMouseEventActuallyIntersect(event))
return false; return false;
if (!HasFocus())
defer_select_all_ = true;
return Textfield::OnMousePressed(event); return Textfield::OnMousePressed(event);
} }
...@@ -159,6 +162,8 @@ class FolderHeaderView::FolderNameView : public views::Textfield, ...@@ -159,6 +162,8 @@ class FolderHeaderView::FolderNameView : public views::Textfield,
if (!HasSelection()) if (!HasSelection())
SelectAll(false); SelectAll(false);
} }
Textfield::OnMouseReleased(event);
} }
bool DoesIntersectRect(const views::View* target, bool DoesIntersectRect(const views::View* target,
......
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