fix(shortcuts): allow clearing keyboard shortcuts in settings

This commit is contained in:
t8y2 committed 2026-06-10 10:25:06 +08:00
1 parent ed6d275ca2
commit 51fe5de98b
9 files changed
+27 -4

No files matched your search

@@ -493,6 +493,7 @@ function onShortcutKeydown(actionId: ShortcutActionId, event: KeyboardEvent) {
}
function formatShortcutPill(shortcut: string): string {
if (!shortcut) return "—";
const isMac = globalThis.navigator?.platform?.toLowerCase().includes("mac") ?? false;
return shortcut
.split("+")
@@ -539,6 +540,10 @@ function resetShortcut(actionId: ShortcutActionId) {
editShortcuts.value = { ...editShortcuts.value, [actionId]: definition.defaultShortcut };
}
function clearShortcut(actionId: ShortcutActionId) {
editShortcuts.value = { ...editShortcuts.value, [actionId]: "" };
}
function setAppLayout(value: "separated" | "classic") {
editAppLayout.value = value;
}
@@ -1746,6 +1751,17 @@ watch(
>
<RotateCcw class="h-4 w-4" />
</Button>
<Button
v-if="editingShortcutId !== definition.id && editShortcuts[definition.id]"
type="button"
variant="ghost"
size="icon"
class="h-7 w-7 shrink-0 text-muted-foreground opacity-0 transition-opacity hover:text-destructive focus-visible:opacity-100 group-hover:opacity-100"
:aria-label="t('settings.shortcutClear')"
@click="clearShortcut(definition.id)"
>
<X class="h-4 w-4" />
</Button>
</div>
<p v-if="shortcutConflicts.includes(definition.id)" class="text-xs text-destructive">
{{ t("settings.shortcutConflict") }}