From d3d50d0f8cb007eaca2dd167c1553d44decca621 Mon Sep 17 00:00:00 2001 From: "mr. m" <91018726+mr-cheffy@users.noreply.github.com> Date: Mon, 23 Feb 2026 00:59:00 +0100 Subject: [PATCH] fix: Fixed urlbar closing when window loses focus, b=closes #7248, p=#12477, c=urlbar --- prefs/firefox/urlbar.yaml | 5 ++ ..._urlbar_closeonwindowblur_preference.patch | 75 +++++++++++++++++++ src/external-patches/manifest.json | 5 ++ 3 files changed, 85 insertions(+) create mode 100644 src/external-patches/firefox/add_urlbar_closeonwindowblur_preference.patch diff --git a/prefs/firefox/urlbar.yaml b/prefs/firefox/urlbar.yaml index 742163a60..8dbbcb5ef 100644 --- a/prefs/firefox/urlbar.yaml +++ b/prefs/firefox/urlbar.yaml @@ -59,3 +59,8 @@ - name: browser.urlbar.suggest.topsites value: true locked: true + +# See https://github.com/zen-browser/desktop/issues/7248 +# We've submitted a patch to Firefox at https://bugzilla.mozilla.org/show_bug.cgi?id=2018499 +- name: browser.urlbar.closeOnWindowBlur + value: false diff --git a/src/external-patches/firefox/add_urlbar_closeonwindowblur_preference.patch b/src/external-patches/firefox/add_urlbar_closeonwindowblur_preference.patch new file mode 100644 index 000000000..e113d4ea4 --- /dev/null +++ b/src/external-patches/firefox/add_urlbar_closeonwindowblur_preference.patch @@ -0,0 +1,75 @@ +diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js +--- a/browser/app/profile/firefox.js ++++ b/browser/app/profile/firefox.js +@@ -411,10 +411,13 @@ + pref("browser.urlbar.maxRichResults", 10); + + // The maximum number of historical search results to show. + pref("browser.urlbar.maxHistoricalSearchSuggestions", 2); + ++// Whether to close the urlbar when blurring the window while the urlbar is focused. ++pref("browser.urlbar.closeOnWindowBlur", true); ++ + // The default behavior for the urlbar can be configured to use any combination + // of the match filters with each additional filter adding more results (union). + pref("browser.urlbar.suggest.bookmark", true); + pref("browser.urlbar.suggest.clipboard", true); + pref("browser.urlbar.suggest.history", true); +diff --git a/browser/components/urlbar/UrlbarPrefs.sys.mjs b/browser/components/urlbar/UrlbarPrefs.sys.mjs +--- a/browser/components/urlbar/UrlbarPrefs.sys.mjs ++++ b/browser/components/urlbar/UrlbarPrefs.sys.mjs +@@ -152,10 +152,13 @@ + ["filter.javascript", true], + + // Feature gate pref for flight status suggestions in the urlbar. + ["flightStatus.featureGate", false], + ++ // Whether to close the urlbar when blurring the window while the urlbar is focused. ++ ["closeOnWindowBlur", true], ++ + // The minimum prefix length of a flight status keyword the user must type to + // trigger the suggestion. 0 means the min length should be taken from Nimbus + // or remote settings. + ["flightStatus.minKeywordLength", 0], + +diff --git a/browser/components/urlbar/UrlbarView.sys.mjs b/browser/components/urlbar/UrlbarView.sys.mjs +--- a/browser/components/urlbar/UrlbarView.sys.mjs ++++ b/browser/components/urlbar/UrlbarView.sys.mjs +@@ -3909,10 +3909,16 @@ + } + } + } + + on_blur() { ++ if ( ++ this.document.commandDispatcher.focusedElement == this.input.inputField && ++ !lazy.UrlbarPrefs.get("closeOnWindowBlur") ++ ) { ++ return; ++ } + // If the view is open without the input being focused, it will not close + // automatically when the window loses focus. We might be in this state + // after a Search Tip is shown on an engine homepage. + if (!lazy.UrlbarPrefs.get("ui.popup.disable_autohide")) { + this.close(); +diff --git a/browser/components/urlbar/content/UrlbarInput.mjs b/browser/components/urlbar/content/UrlbarInput.mjs +--- a/browser/components/urlbar/content/UrlbarInput.mjs ++++ b/browser/components/urlbar/content/UrlbarInput.mjs +@@ -4783,10 +4783,16 @@ + } + } + + _on_blur(event) { + lazy.logger.debug("Blur Event"); ++ if ( ++ this.document.commandDispatcher.focusedElement == this.inputField && ++ !lazy.UrlbarPrefs.get("closeOnWindowBlur") ++ ) { ++ return; ++ } + // We cannot count every blur events after a missed engagement as abandoment + // because the user may have clicked on some view element that executes + // a command causing a focus change. For example opening preferences from + // the oneoff settings button. + // For now we detect that case by discarding the event on command, but we + diff --git a/src/external-patches/manifest.json b/src/external-patches/manifest.json index f73f598ed..6a1dbdb96 100644 --- a/src/external-patches/manifest.json +++ b/src/external-patches/manifest.json @@ -17,6 +17,11 @@ "overridden": "overriden" } }, + { + "type": "phabricator", + "id": "D284404", + "name": "Add urlbar closeOnWindowBlur preference" + }, { "type": "local", "path": "firefox/no_liquid_glass_icon.patch"