Commit 1b213ac4 authored by Tommy Li's avatar Tommy Li Committed by Commit Bot

[omnibox] Fine-tune the up and down arrow behavior for ZeroSuggest

This CL allows proper reverting via arrow-key for On Focus Query
Suggestions.

Previously, we forbade reverting via arrow key for all on-focus
suggestions, and this was to fix the NTP case, which does not have a
verbatim match at as the default match.

But for on-focus query refinements (on SERP), the first match is indeed
a verbatim search match, so we should allow those.

Bug: 1012990, 963173
Change-Id: I976ff4f39271ffd8fe84c5f12622733c41e0124b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1873132
Commit-Queue: Tommy Li <tommycli@chromium.org>
Reviewed-by: default avatarMoe Ahmadi <mahmadi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708228}
parent c1c79e9e
......@@ -1192,11 +1192,13 @@ void OmniboxEditModel::OnUpOrDownKeyPressed(int count) {
// we should revert the temporary text same as what pressing escape would
// have done.
//
// This doesn't apply for on-focus suggestions, for which the first result
// can be completely distinct from the omnibox contents. We enforce that
// via user_input_in_progress_, which is false for ZeroSuggest.
// Reverting, however, does not make sense for on-focus suggestions
// (user_input_in_progress_ is false) unless the first result is a
// verbatim match of the omnibox input (on-focus query refinements on SERP).
const size_t line_no = GetNewSelectedLine(count);
if (has_temporary_text_ && line_no == 0 && user_input_in_progress_) {
if (has_temporary_text_ && line_no == 0 &&
(user_input_in_progress_ ||
result().default_match()->IsVerbatimType())) {
RevertTemporaryTextAndPopup();
} else {
popup_model()->MoveTo(line_no);
......
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