commit f397bdf66055ef49abed22f3dab0b72831cfc4bb
parent 44663f537543b39324cf06f9ecd6dfb591440b27
Author: Dão Gottwald <dao@mozilla.com>
Date: Thu, 8 Jan 2026 09:37:27 +0000
Bug 2007267 - Alt+up/down should open the unified search button even if the result view is closed. r=daleharvey
Differential Revision: https://phabricator.services.mozilla.com/D278111
Diffstat:
3 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/browser/components/urlbar/SearchModeSwitcher.sys.mjs b/browser/components/urlbar/SearchModeSwitcher.sys.mjs
@@ -254,8 +254,7 @@ export class SearchModeSwitcher {
}
/**
- * If the user presses Option+Up or Option+Down while navigating the urlbar results
- * we open the engine list.
+ * If the user presses Option+Up or Option+Down we open the engine list.
*
* @param {KeyboardEvent} event
* The key down event.
diff --git a/browser/components/urlbar/UrlbarController.sys.mjs b/browser/components/urlbar/UrlbarController.sys.mjs
@@ -314,7 +314,7 @@ export class UrlbarController {
return;
}
- if (this.view.isOpen && executeAction && this._lastQueryContextWrapper) {
+ if (executeAction) {
// In native inputs on most platforms, Shift+Up/Down moves the caret to the
// start/end of the input and changes its selection, so in that case defer
// handling to the input instead of changing the view's selection.
@@ -326,11 +326,11 @@ export class UrlbarController {
return;
}
- let { queryContext } = this._lastQueryContextWrapper;
let handled = false;
if (lazy.UrlbarPrefs.get("scotchBonnet.enableOverride")) {
handled = this.input.searchModeSwitcher.handleKeyDown(event);
- } else {
+ } else if (this.view.isOpen && this._lastQueryContextWrapper) {
+ let { queryContext } = this._lastQueryContextWrapper;
handled = this.view.oneOffSearchButtons?.handleKeyDown(
event,
this.view.visibleRowCount,
diff --git a/browser/components/urlbar/tests/browser/browser_searchModeSwitcher_basic.js b/browser/components/urlbar/tests/browser/browser_searchModeSwitcher_basic.js
@@ -884,8 +884,10 @@ 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");
+add_task(async function open_with_alt_option_with_open_view() {
+ info(
+ "Open the urlbar and searchmode switcher popup with Arrow Down + Alt/Option keys while the results view is open"
+ );
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: "",
@@ -902,3 +904,19 @@ add_task(async function open_with_option() {
EventUtils.synthesizeKey("KEY_Escape");
await popupHidden;
});
+
+add_task(async function open_with_alt_option_with_closed_view() {
+ info(
+ "Open the urlbar and searchmode switcher popup with Arrow Up + Alt/Option keys while the results view is closed"
+ );
+ let promiseMenuOpen = BrowserTestUtils.waitForPopupEvent(
+ UrlbarTestUtils.searchModeSwitcherPopup(window),
+ "shown"
+ );
+ EventUtils.synthesizeKey("KEY_ArrowUp", { altKey: true });
+ await promiseMenuOpen;
+
+ let popupHidden = UrlbarTestUtils.searchModeSwitcherPopupClosed(window);
+ EventUtils.synthesizeKey("KEY_Escape");
+ await popupHidden;
+});