Commit 2bfaee3c authored by Mike Wasserman's avatar Mike Wasserman Committed by Commit Bot

KSV: Only clear search on esc/back key press.

Avoid clearing the text/search on escape key release only.
(eg. when a context menu closes, consuming the press event)

Bug: NONE
Test: KSV search not cleared pressing escape to close a context menu.
Change-Id: Iaee63b9e31bf371ec3d95fd9ef4b688c0254b697
Reviewed-on: https://chromium-review.googlesource.com/c/1295171Reviewed-by: default avatarTao Wu <wutao@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Michael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601786}
parent 8d774d9e
...@@ -56,15 +56,16 @@ void KSVSearchBoxView::GetAccessibleNodeData(ui::AXNodeData* node_data) { ...@@ -56,15 +56,16 @@ void KSVSearchBoxView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
void KSVSearchBoxView::OnKeyEvent(ui::KeyEvent* event) { void KSVSearchBoxView::OnKeyEvent(ui::KeyEvent* event) {
const ui::KeyboardCode key = event->key_code(); const ui::KeyboardCode key = event->key_code();
const bool is_escape_key = (key == ui::VKEY_ESCAPE); if ((key != ui::VKEY_ESCAPE && key != ui::VKEY_BROWSER_BACK) ||
if (!is_escape_key && key != ui::VKEY_BROWSER_BACK) event->type() != ui::ET_KEY_PRESSED) {
return; return;
}
event->SetHandled(); event->SetHandled();
// |VKEY_BROWSER_BACK| will only clear all the text. // |VKEY_BROWSER_BACK| will only clear all the text.
ClearSearch(); ClearSearch();
// |VKEY_ESCAPE| will clear text and exit search mode directly. // |VKEY_ESCAPE| will clear text and exit search mode directly.
if (is_escape_key) if (key == ui::VKEY_ESCAPE)
SetSearchBoxActive(false, event->type()); SetSearchBoxActive(false, event->type());
} }
......
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