Commit e44a32d3 authored by Moe Ahmadi's avatar Moe Ahmadi Committed by Commit Bot

[NTP][Realbox] Allows realbox suggestions to be deleted using 'Enter' key

crrev.com/c/2206222 broke this behavior by making the outer <div>
focusable and preventing the inner <button> to which the click handler
is attached to from gaining focus.

This CL restores the original behavior by attaching the handlers to the
outer focusable container. It also simplifies the a11y setup by making
the outer container a real button and the inner container an unfocusable
div.

Bug: 1095549
Change-Id: Iacc1d5f673545cd25cc93965463d57d7447a7ff3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2264801
Commit-Queue: Moe Ahmadi <mahmadi@chromium.org>
Commit-Queue: Tommy Li <tommycli@chromium.org>
Auto-Submit: Moe Ahmadi <mahmadi@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782017}
parent 2ae7fb30
...@@ -1686,29 +1686,25 @@ function renderAutocompleteMatches(matches, suggestionGroupsMap) { ...@@ -1686,29 +1686,25 @@ function renderAutocompleteMatches(matches, suggestionGroupsMap) {
* @param {!function()} callback * @param {!function()} callback
*/ */
function createActionButton(callback) { function createActionButton(callback) {
const icon = document.createElement('button'); const icon = document.createElement('div');
icon.classList.add(CLASSES.REMOVE_ICON); icon.classList.add(CLASSES.REMOVE_ICON);
icon.tabIndex = -1; const action = document.createElement('button');
icon.onmousedown = e => { action.classList.add(CLASSES.REMOVE_MATCH);
action.appendChild(icon);
action.onmousedown = e => {
e.preventDefault(); // Stops default browser action (focus) e.preventDefault(); // Stops default browser action (focus)
}; };
icon.onauxclick = e => { action.onauxclick = e => {
if (e.button == 1) { if (e.button == 1) {
// Middle click on delete should just noop for now (matches omnibox). // Middle click on delete should just noop for now (matches omnibox).
e.preventDefault(); e.preventDefault();
} }
}; };
icon.onclick = e => { action.onclick = e => {
callback(); callback();
e.preventDefault(); // Stops default browser action (navigation) e.preventDefault(); // Stops default browser action (navigation)
}; };
const action = document.createElement('div');
action.classList.add(CLASSES.REMOVE_MATCH);
action.tabIndex = 0;
action.setAttribute('role', 'button');
action.appendChild(icon);
return action; return action;
} }
......
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