Bug 1086524 - Focus window on Esc in address bar r=dao,urlbar-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D218893
This commit is contained in:
Collin Richards
2024-10-16 11:47:11 +00:00
parent 03e5396a93
commit 9f857b20cb
9 changed files with 133 additions and 11 deletions

View File

@@ -276,6 +276,7 @@ export class UrlbarController {
* will be deferred by the event bufferer, but preventDefault() and friends
* should still happen synchronously.
*/
// eslint-disable-next-line complexity
handleKeyNavigation(event, executeAction = true) {
const isMac = AppConstants.platform == "macosx";
// Handle readline/emacs-style navigation bindings on Mac.
@@ -321,6 +322,12 @@ export class UrlbarController {
if (executeAction) {
if (this.view.isOpen) {
this.view.close();
} else if (lazy.UrlbarPrefs.get("focusContentDocumentOnEsc")) {
if (this.browserWindow.gBrowser.userTypedValue) {
this.input.handleRevert(true);
} else {
this.browserWindow.gBrowser.selectedBrowser.focus();
}
} else {
this.input.handleRevert({
escapeSearchMode: true,