Commit fdee2705 authored by Dan Beam's avatar Dan Beam Committed by Commit Bot

Local NTP, Realbox: pressing Arrow up/down should reshow matches

Fixed: 1015685
Change-Id: Ie5241e62ccf06c854a578634cda968a55c21ea80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1867850
Auto-Submit: Dan Beam <dbeam@chromium.org>
Reviewed-by: default avatarMoe Ahmadi <mahmadi@chromium.org>
Commit-Queue: Dan Beam <dbeam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707218}
parent a8e39e68
......@@ -1328,7 +1328,10 @@ function onRealboxWrapperKeydown(e) {
}
if (!areRealboxMatchesVisible()) {
// Only update output if matches are showing.
if (key === 'ArrowUp' || key === 'ArrowDown') {
setRealboxMatchesVisible(true);
e.preventDefault();
}
return;
}
......
......@@ -766,3 +766,40 @@ test.realbox.testPressEnterAfterFocusout = function() {
assertTrue(clicked);
};
test.realbox.testArrowUpDownShowsMatchesWhenHidden = function() {
test.realbox.realboxEl.value = 'hello world';
test.realbox.realboxEl.dispatchEvent(new CustomEvent('input'));
chrome.embeddedSearch.searchBox.onqueryautocompletedone({
input: test.realbox.realboxEl.value,
matches: [test.realbox.getSearchMatch(), test.realbox.getUrlMatch()],
});
test.realbox.realboxEl.dispatchEvent(new Event('focusout', {
bubbles: true,
cancelable: true,
target: test.realbox.realboxEl,
relatedTarget: document.body,
}));
assertFalse(test.realbox.wrapperEl.classList.contains(
test.realbox.CLASSES.SHOW_MATCHES));
test.realbox.realboxEl.dispatchEvent(new Event('focusin', {
bubbles: true,
cancelable: true,
target: test.realbox.realboxEl,
}));
const arrowDown = new KeyboardEvent('keydown', {
bubbles: true,
cancelable: true,
key: 'ArrowDown',
});
test.realbox.realboxEl.dispatchEvent(arrowDown);
assertTrue(arrowDown.defaultPrevented);
assertTrue(test.realbox.wrapperEl.classList.contains(
test.realbox.CLASSES.SHOW_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