Commit 3012716f authored by Moe Ahmadi's avatar Moe Ahmadi Committed by Commit Bot

[realbox] Allows navigation when input has leading whitespace

Whitespaces are removed from the beginning of the input string returned
in the AutocompleteResult. This should be taken into account when
deciding whether the results are fresh when they arrive as well as when
navigating to them. This CL accounts for that subtlety in the latter.

Fixed: 1102345
Change-Id: I2f34805dfd2cb02aed6659f497347c93771e5666
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2560070Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Commit-Queue: Moe Ahmadi <mahmadi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#831139}
parent 8652e776
......@@ -539,7 +539,9 @@ class RealboxElement extends PolymerElement {
if (e.key === 'Enter') {
if ([this.$.matches, this.$.input].includes(e.target)) {
if (this.lastQueriedInput_ === decodeString16(this.result_.input)) {
if (this.lastQueriedInput_ !== null &&
this.lastQueriedInput_.trimLeft() ===
decodeString16(this.result_.input)) {
if (this.selectedMatch_) {
this.navigateToMatch_(this.selectedMatchIndex_, e);
}
......
......@@ -809,7 +809,7 @@ suite('NewTabPageRealboxTest', () => {
// Input is expected to have been focused before any navigation.
realbox.$.input.dispatchEvent(new Event('focus'));
realbox.$.input.value = 'hello';
realbox.$.input.value = ' hello ';
realbox.$.input.dispatchEvent(new CustomEvent('input'));
const matches = [
......@@ -860,7 +860,7 @@ suite('NewTabPageRealboxTest', () => {
// Input is expected to have been focused before any navigation.
realbox.$.input.dispatchEvent(new Event('focus'));
realbox.$.input.value = 'hello ';
realbox.$.input.value = ' hello ';
realbox.$.input.dispatchEvent(new CustomEvent('input'));
const matches =
......
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