Commit d9ecdb14 authored by manukh's avatar manukh Committed by Commit Bot

[chrome://omnibox omnibox] 'space'/'enter' to activate focused buttons.

The copy, paste, download, upload, and batch buttons can be focused with
the tab key or mouse clicks. However, pressing 'space' or 'enter' does
not activate the focused button.

The download, upload, and batch buttons are labels wrapping invisible
file inputs. This is required in order to style file inputs. The copy
and paste buttons are spans for consistency with the other 3 buttons.

Since neither spans nor labels are typically intractable, they don't
inherently process 'space' and 'enter' key presses when focused as
standard buttons do. This CL explicitly adds a keypress listener to do
so.

Bug: 1040024
Change-Id: I182a238b8daf3bd25d874b090752173ae1738c41
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1992309
Commit-Queue: manuk hovanesian <manukh@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#729853}
parent 38a58c54
...@@ -21,15 +21,24 @@ export class OmniboxElement extends HTMLElement { ...@@ -21,15 +21,24 @@ export class OmniboxElement extends HTMLElement {
} }
/** /**
* Get an element that's known to exist within this OmniboxElement. * Finds the 1st element matching the query within the local shadow root. At
* Searches local shadow root for element by query. * least 1 matching element should exist.
* @param {string} query * @param {string} query
* @return {!Element} * @return {!Element}
*/ */
$$(query) { $(query) {
return OmniboxElement.getByQuery_(query, this.shadowRoot); return OmniboxElement.getByQuery_(query, this.shadowRoot);
} }
/**
* Finds all elements matching the query within the local shadow root.
* @param {string} query
* @return {!NodeList<!Element>}
*/
$$(query) {
return (this.shadowRoot || document).querySelectorAll(query);
}
/** /**
* Get a template that's known to exist within the DOM document. * Get a template that's known to exist within the DOM document.
* @param {string} templateId * @param {string} templateId
......
...@@ -94,7 +94,7 @@ export class OmniboxOutput extends OmniboxElement { ...@@ -94,7 +94,7 @@ export class OmniboxOutput extends OmniboxElement {
*/ */
clearResultsGroups_() { clearResultsGroups_() {
this.resultsGroups_ = []; this.resultsGroups_ = [];
clearChildren(this.$$('#contents')); clearChildren(this.$('#contents'));
} }
/** /**
...@@ -104,7 +104,7 @@ export class OmniboxOutput extends OmniboxElement { ...@@ -104,7 +104,7 @@ export class OmniboxOutput extends OmniboxElement {
createResultsGroup_(response) { createResultsGroup_(response) {
const resultsGroup = OutputResultsGroup.create(response); const resultsGroup = OutputResultsGroup.create(response);
this.resultsGroups_.push(resultsGroup); this.resultsGroups_.push(resultsGroup);
this.$$('#contents').appendChild(resultsGroup); this.$('#contents').appendChild(resultsGroup);
this.updateDisplay_(); this.updateDisplay_();
this.updateFilterHighlights_(); this.updateFilterHighlights_();
...@@ -238,17 +238,16 @@ class OutputResultsGroup extends OmniboxElement { ...@@ -238,17 +238,16 @@ class OutputResultsGroup extends OmniboxElement {
/** @private {!Array<!Element>} */ /** @private {!Array<!Element>} */
this.innerHeaders_ = []; this.innerHeaders_ = [];
customElements.whenDefined(this.$$('output-results-details').localName) customElements.whenDefined(this.$('output-results-details').localName)
.then( .then(() => this.$('output-results-details').setDetails(this.details_));
() => this.$$('output-results-details').setDetails(this.details_));
this.$$('#table').appendChild(this.renderHeader_()); this.$('#table').appendChild(this.renderHeader_());
this.$$('#table').appendChild(this.combinedResults); this.$('#table').appendChild(this.combinedResults);
this.individualResultsList.forEach(results => { this.individualResultsList.forEach(results => {
const innerHeader = this.renderInnerHeader_(results); const innerHeader = this.renderInnerHeader_(results);
this.innerHeaders_.push(innerHeader); this.innerHeaders_.push(innerHeader);
this.$$('#table').appendChild(innerHeader); this.$('#table').appendChild(innerHeader);
this.$$('#table').appendChild(results); this.$('#table').appendChild(results);
}); });
} }
...@@ -288,7 +287,7 @@ class OutputResultsGroup extends OmniboxElement { ...@@ -288,7 +287,7 @@ class OutputResultsGroup extends OmniboxElement {
updateVisibility(showIncompleteResults, showDetails, showAllProviders) { updateVisibility(showIncompleteResults, showDetails, showAllProviders) {
// Show the details section above each table if showDetails or // Show the details section above each table if showDetails or
// showIncompleteResults are true. // showIncompleteResults are true.
this.$$('output-results-details').hidden = this.$('output-results-details').hidden =
!showDetails && !showIncompleteResults; !showDetails && !showIncompleteResults;
// Show individual results when showAllProviders is true. // Show individual results when showAllProviders is true.
...@@ -343,12 +342,12 @@ class OutputResultsDetails extends OmniboxElement { ...@@ -343,12 +342,12 @@ class OutputResultsDetails extends OmniboxElement {
/** @param {ResultsDetails} details */ /** @param {ResultsDetails} details */
setDetails(details) { setDetails(details) {
this.$$('#cursor-position').textContent = details.cursorPosition; this.$('#cursor-position').textContent = details.cursorPosition;
this.$$('#time').textContent = details.time; this.$('#time').textContent = details.time;
this.$$('#done').textContent = details.done; this.$('#done').textContent = details.done;
this.$$('#type').textContent = details.type; this.$('#type').textContent = details.type;
this.$$('#host').textContent = details.host; this.$('#host').textContent = details.host;
this.$$('#is-typed-host').textContent = details.isTypedHost; this.$('#is-typed-host').textContent = details.isTypedHost;
} }
} }
......
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