mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 10:15:41 +00:00
Bug 1515285 - Implement selecting switch-to-tab results by keyboard. r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D16023 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
961eb5b518
commit
0e43f06aef
@ -214,6 +214,16 @@ class UrlbarInput {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Use the selected result if we have one; this should always be the case
|
||||
// when the view is open.
|
||||
let result = this.view.selectedResult;
|
||||
if (result) {
|
||||
this.pickResult(event, result);
|
||||
return;
|
||||
}
|
||||
|
||||
// Use the current value if we don't have a UrlbarMatch e.g. because the
|
||||
// view is closed.
|
||||
let url = this.value;
|
||||
if (!url) {
|
||||
return;
|
||||
@ -268,6 +278,8 @@ class UrlbarInput {
|
||||
pickResult(event, result) {
|
||||
this.setValueFromResult(result);
|
||||
|
||||
this.view.close();
|
||||
|
||||
// TODO: Work out how we get the user selection behavior, probably via passing
|
||||
// it in, since we don't have the old autocomplete controller to work with.
|
||||
// BrowserUsageTelemetry.recordUrlbarSelectedResultMethod(
|
||||
|
@ -54,6 +54,19 @@ class UrlbarView {
|
||||
return this.panel.state == "open" || this.panel.state == "showing";
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {UrlbarMatch}
|
||||
* The currently selected result.
|
||||
*/
|
||||
get selectedResult() {
|
||||
if (!this.isOpen) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let resultIndex = this._selected.getAttribute("resultIndex");
|
||||
return this._queryContext.results[resultIndex];
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects the next or previous view item. An item could be an autocomplete
|
||||
* result or a one-off search button.
|
||||
@ -303,7 +316,6 @@ class UrlbarView {
|
||||
if (result) {
|
||||
this.input.pickResult(event, result);
|
||||
}
|
||||
this.close();
|
||||
}
|
||||
|
||||
_on_overflow(event) {
|
||||
|
Loading…
Reference in New Issue
Block a user