Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Ensure Cmd + Enter in URL bar always opens in a new tab #5449

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ engine/
firefox-*/
node_modules/
.surfer/
.DS_Store

__pycache__/
dist/
Expand Down
52 changes: 37 additions & 15 deletions src/browser/components/urlbar/UrlbarInput-sys-mjs.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/browser/components/urlbar/UrlbarInput.sys.mjs b/browser/components/urlbar/UrlbarInput.sys.mjs
index 50968dc04b527438acf30151f0c2e92f8b45097c..ff77a2407b8ca628bcad06a9822ba2dbf0d43a51 100644
index 50968dc04b527438acf30151f0c2e92f8b45097c..4561c5d89d6c14645b49a5d40db18024b58a5f21 100644
--- a/browser/components/urlbar/UrlbarInput.sys.mjs
+++ b/browser/components/urlbar/UrlbarInput.sys.mjs
@@ -67,6 +67,13 @@ XPCOMUtils.defineLazyPreferenceGetter(
Expand Down Expand Up @@ -89,25 +89,47 @@ index 50968dc04b527438acf30151f0c2e92f8b45097c..ff77a2407b8ca628bcad06a9822ba2db
this.removeAttribute("breakout-extend");
this.#updateTextboxPosition();
}
@@ -2946,7 +2978,7 @@ export class UrlbarInput {
@@ -3284,6 +3316,9 @@ export class UrlbarInput {
* @returns {"current" | "tabshifted" | "tab" | "save" | "window"}
*/
_trimValue(val) {
let trimmedValue = lazy.UrlbarPrefs.get("trimURLs")
- ? lazy.BrowserUIUtils.trimURL(val)
+ ? this._zenTrimURL(val)
: val;
// Only trim value if the directionality doesn't change to RTL and we're not
// showing a strikeout https protocol.
@@ -3305,7 +3337,7 @@ export class UrlbarInput {
_whereToOpen(event) {
+ // Helper to check for meta/alt/altgraph modifiers, useful for determining if we
+ // should reuse the current tab
+ const altMetaModifier = event.metaKey || event.altKey || event.getModifierState("AltGraph");
let isKeyboardEvent = KeyboardEvent.isInstance(event);
let reuseEmpty = isKeyboardEvent;
let where = undefined;
@@ -3305,18 +3340,25 @@ export class UrlbarInput {
} else {
where = lazy.BrowserUtils.whereToOpenLink(event, false, false);
}
- if (lazy.UrlbarPrefs.get("openintab")) {
+ if (lazy.UrlbarPrefs.get("openintab") || this.hasAttribute("zen-newtab")) {
if (where == "current") {
where = "tab";
} else if (where == "tab") {
@@ -3859,6 +3891,11 @@ export class UrlbarInput {
- } else if (where == "tab") {
+ } else if (
+ where == "tab" &&
+ !altMetaModifier
+ ) {
where = "current";
}
- reuseEmpty = true;
+ if (!altMetaModifier) {
+ reuseEmpty = true;
+ }
}
+
if (
where == "tab" &&
reuseEmpty &&
- this.window.gBrowser.selectedTab.isEmpty
+ this.window.gBrowser.selectedTab.isEmpty &&
+ !altMetaModifier
) {
where = "current";
}
@@ -3859,6 +3901,11 @@ export class UrlbarInput {
}

_on_click(event) {
Expand All @@ -119,7 +141,7 @@ index 50968dc04b527438acf30151f0c2e92f8b45097c..ff77a2407b8ca628bcad06a9822ba2db
if (
event.target == this.inputField ||
event.target == this._inputContainer ||
@@ -3930,7 +3967,7 @@ export class UrlbarInput {
@@ -3930,7 +3977,7 @@ export class UrlbarInput {
}
}

Expand All @@ -128,7 +150,7 @@ index 50968dc04b527438acf30151f0c2e92f8b45097c..ff77a2407b8ca628bcad06a9822ba2db
this.view.autoOpen({ event });
} else {
if (this._untrimOnFocusAfterKeydown) {
@@ -3970,9 +4007,12 @@ export class UrlbarInput {
@@ -3970,9 +4017,12 @@ export class UrlbarInput {
}

_on_mousedown(event) {
Expand All @@ -142,7 +164,7 @@ index 50968dc04b527438acf30151f0c2e92f8b45097c..ff77a2407b8ca628bcad06a9822ba2db

if (
event.target != this.inputField &&
@@ -3982,8 +4022,8 @@ export class UrlbarInput {
@@ -3982,8 +4032,8 @@ export class UrlbarInput {
break;
}

Expand Down