From 4bfb815297c62ae684c63762d2fecf2823482a1e Mon Sep 17 00:00:00 2001
From: Aryan Rawlani <44131905+aryanrawlani28@users.noreply.github.com>
Date: Wed, 8 Oct 2025 21:11:25 +0530
Subject: [PATCH] =?UTF-8?q?feat:=20settings=20->=20shortcuts:=20show=20con?=
=?UTF-8?q?flicting=20shortcut=C2=A0label,=20p=3D#10735?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../browser/preferences/zen-preferences.ftl | 2 +-
.../components/preferences/zen-settings.js | 31 ++++++++++++++-----
src/zen/kbs/ZenKeyboardShortcuts.mjs | 9 ++++--
3 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/locales/en-US/browser/browser/preferences/zen-preferences.ftl b/locales/en-US/browser/browser/preferences/zen-preferences.ftl
index 6d400ca0e..43f48460d 100644
--- a/locales/en-US/browser/browser/preferences/zen-preferences.ftl
+++ b/locales/en-US/browser/browser/preferences/zen-preferences.ftl
@@ -89,7 +89,7 @@ zen-settings-workspaces-hide-default-container-indicator =
.label = Hide the default container indicator in the tab bar
zen-key-unsaved = Unsaved shortcut! Please save it by clicking the "Escape" key after retyping it.
-zen-key-conflict = Conflict with another shortcut
+zen-key-conflict = Conflicts with { $group } -> { $shortcut }
pane-zen-theme-title = Theme Settings
diff --git a/src/browser/components/preferences/zen-settings.js b/src/browser/components/preferences/zen-settings.js
index b37ba5dcb..553ddc109 100644
--- a/src/browser/components/preferences/zen-settings.js
+++ b/src/browser/components/preferences/zen-settings.js
@@ -973,7 +973,7 @@ var gZenCKSSettings = {
this._latestValidKey = null;
return;
} else if (shortcut == 'Escape' && !modifiersActive) {
- const hasConflicts = gZenKeyboardShortcutsManager.checkForConflicts(
+ const { hasConflicts, conflictShortcut } = gZenKeyboardShortcutsManager.checkForConflicts(
this._latestValidKey ? this._latestValidKey : shortcut,
this._latestModifier ? this._latestModifier : modifiers,
this._currentActionID
@@ -986,12 +986,29 @@ var gZenCKSSettings = {
input.classList.add(`${ZEN_CKS_INPUT_FIELD_CLASS}-invalid`);
}
input.classList.remove(`${ZEN_CKS_INPUT_FIELD_CLASS}-unsafed`);
- if (hasConflicts && !input.nextElementSibling) {
- input.after(
- window.MozXULElement.parseXULToFragment(`
-
- `)
- );
+
+ if (hasConflicts) {
+ const shortcutL10nKey =
+ zenMissingKeyboardShortcutL10n[conflictShortcut.getID()] ??
+ conflictShortcut.getL10NID();
+
+ const [group, shortcut] = await document.l10n.formatValues([
+ { id: `${ZEN_CKS_GROUP_PREFIX}-${conflictShortcut.getGroup()}` },
+ { id: shortcutL10nKey },
+ ]);
+
+ if (!input.nextElementSibling) {
+ input.after(
+ window.MozXULElement.parseXULToFragment(`
+
+ `)
+ );
+ }
+
+ document.l10n.setAttributes(input.nextElementSibling, 'zen-key-conflict', {
+ group: group ?? '',
+ shortcut: shortcut ?? '',
+ });
}
} else {
input.classList.remove(`${ZEN_CKS_INPUT_FIELD_CLASS}-editing`);
diff --git a/src/zen/kbs/ZenKeyboardShortcuts.mjs b/src/zen/kbs/ZenKeyboardShortcuts.mjs
index ad7a7c5f4..0fb29b239 100644
--- a/src/zen/kbs/ZenKeyboardShortcuts.mjs
+++ b/src/zen/kbs/ZenKeyboardShortcuts.mjs
@@ -1343,11 +1343,16 @@ var gZenKeyboardShortcutsManager = {
targetShortcut.getModifiers().equals(modifiers) &&
targetShortcut.getKeyNameOrCode()?.toLowerCase() == realShortcut
) {
- return true;
+ return {
+ hasConflicts: true,
+ conflictShortcut: targetShortcut,
+ };
}
}
- return false;
+ return {
+ hasConflicts: false,
+ };
},
getShortcutFromCommand(command) {