commit a4722fa9a71c73d054fade6c7fe8be7ebb67fa1b
parent 4afd0a907716a68255010e42b894aac3acc5d015
Author: Dale Harvey <dale@arandomurl.com>
Date: Thu, 23 Oct 2025 09:25:05 +0000
Bug 1962200 - Open unified search panel with Option + Up/Down. r=daisuke,urlbar-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D269483
Diffstat:
3 files changed, 62 insertions(+), 9 deletions(-)
diff --git a/browser/components/urlbar/SearchModeSwitcher.sys.mjs b/browser/components/urlbar/SearchModeSwitcher.sys.mjs
@@ -242,6 +242,30 @@ export class SearchModeSwitcher {
}
}
+ /**
+ * If the user presses Option+Up or Option+Down while navigating the urlbar results
+ * we open the engine list.
+ *
+ * @param {KeyboardEvent} event
+ * The key down event.
+ */
+ handleKeyDown(event) {
+ if (
+ (event.keyCode == KeyEvent.DOM_VK_UP ||
+ event.keyCode == KeyEvent.DOM_VK_DOWN) &&
+ event.altKey
+ ) {
+ this.#input.controller.focusOnUnifiedSearchButton();
+ this.#popup.openPopup(null, {
+ triggerEvent: event,
+ });
+ event.stopPropagation();
+ event.preventDefault();
+ return true;
+ }
+ return false;
+ }
+
async updateSearchIcon() {
let searchMode = this.#input.searchMode;
diff --git a/browser/components/urlbar/UrlbarController.sys.mjs b/browser/components/urlbar/UrlbarController.sys.mjs
@@ -321,12 +321,17 @@ export class UrlbarController {
}
let { queryContext } = this._lastQueryContextWrapper;
- let handled = this.view.oneOffSearchButtons?.handleKeyDown(
- event,
- this.view.visibleRowCount,
- this.view.allowEmptySelection,
- queryContext.searchString
- );
+ let handled = false;
+ if (lazy.UrlbarPrefs.get("scotchBonnet.enableOverride")) {
+ handled = this.input.searchModeSwitcher.handleKeyDown(event);
+ } else {
+ handled = this.view.oneOffSearchButtons?.handleKeyDown(
+ event,
+ this.view.visibleRowCount,
+ this.view.allowEmptySelection,
+ queryContext.searchString
+ );
+ }
if (handled) {
return;
}
@@ -390,14 +395,14 @@ export class UrlbarController {
// Button. Then make urlbar results selectable by tab + shift.
event.preventDefault();
this.view.selectedRowIndex = -1;
- this.#focusOnUnifiedSearchButton();
+ this.focusOnUnifiedSearchButton();
break;
} else if (
!this.view.selectedElement &&
this.input.focusedViaMousedown
) {
if (event.shiftKey) {
- this.#focusOnUnifiedSearchButton();
+ this.focusOnUnifiedSearchButton();
} else {
this.view.selectBy(1, {
userPressedTab: true,
@@ -718,7 +723,7 @@ export class UrlbarController {
}
}
- #focusOnUnifiedSearchButton() {
+ focusOnUnifiedSearchButton() {
this.input.setUnifiedSearchButtonAvailability(true);
/** @type {HTMLElement} */
diff --git a/browser/components/urlbar/tests/browser/browser_searchModeSwitcher_basic.js b/browser/components/urlbar/tests/browser/browser_searchModeSwitcher_basic.js
@@ -6,6 +6,11 @@ add_setup(async function setup() {
await SpecialPowers.pushPrefEnv({
set: [["browser.urlbar.scotchBonnet.enableOverride", true]],
});
+ registerCleanupFunction(() => {
+ Services.prefs.clearUserPref(
+ "browser.urlbar.perplexity.hasBeenInSearchMode"
+ );
+ });
});
add_task(async function open_settings() {
@@ -867,6 +872,25 @@ add_task(async function test_search_mode_switcher_private_engine_icon() {
await SpecialPowers.popPrefEnv();
});
+add_task(async function open_with_option() {
+ info("Open the urlbar and searchmode switcher popup with arrow+option key");
+ await UrlbarTestUtils.promiseAutocompleteResultPopup({
+ window,
+ value: "",
+ });
+
+ let promiseMenuOpen = BrowserTestUtils.waitForPopupEvent(
+ UrlbarTestUtils.searchModeSwitcherPopup(window),
+ "shown"
+ );
+ EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true });
+ await promiseMenuOpen;
+
+ let popupHidden = UrlbarTestUtils.searchModeSwitcherPopupClosed(window);
+ EventUtils.synthesizeKey("KEY_Escape");
+ await popupHidden;
+});
+
function getSeachModeSwitcherIcon(window) {
let searchModeSwitcherButton = window.gURLBar.querySelector(
".searchmode-switcher-icon"