From 51be6d579fcac2dda6fd9f3183a037a71780faec Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Fri, 27 Mar 2026 00:29:49 +0100 Subject: [PATCH] refactor(shortcuts): two-column layout for shortcuts dialog Split the shortcuts dialog into a two-column grid layout: - Left column: General + Navigation groups - Right column: Chat group (which has the most shortcuts) Reduces vertical height so the full list is visible without scrolling. Widen dialog to max-w-4xl (w-11/12) to accommodate both columns. Simplify Kbd/group styling for cleaner visual density. --- .../Nav/KeyboardShortcutsDialog.tsx | 104 +++++++++++------- 1 file changed, 67 insertions(+), 37 deletions(-) diff --git a/client/src/components/Nav/KeyboardShortcutsDialog.tsx b/client/src/components/Nav/KeyboardShortcutsDialog.tsx index 32cd89489e..4868fe00b5 100644 --- a/client/src/components/Nav/KeyboardShortcutsDialog.tsx +++ b/client/src/components/Nav/KeyboardShortcutsDialog.tsx @@ -1,10 +1,10 @@ import { memo, useMemo } from 'react'; -import { useRecoilState } from 'recoil'; import { X } from 'lucide-react'; +import { useRecoilState } from 'recoil'; import { OGDialog, OGDialogContent, OGDialogTitle, OGDialogClose } from '@librechat/client'; +import type { ShortcutDefinition } from '~/hooks/useKeyboardShortcuts'; import type { TranslationKeys } from '~/hooks/useLocalize'; import { shortcutDefinitions, isMac } from '~/hooks/useKeyboardShortcuts'; -import type { ShortcutDefinition } from '~/hooks/useKeyboardShortcuts'; import { useLocalize } from '~/hooks'; import { cn } from '~/utils'; import store from '~/store'; @@ -13,7 +13,7 @@ type GroupedShortcuts = Record + {children} ); @@ -31,8 +31,8 @@ function KeyCombo({ keys }: { keys: string[] }) { function ShortcutRow({ label, keys }: { label: string; keys: string[] }) { return ( -
- {label} +
+ {label}
); @@ -42,6 +42,32 @@ function parseKeys(display: string): string[] { return display.split(/([+\s]+)/).filter((k) => k.trim().length > 0 && k !== '+'); } +function ShortcutGroup({ + groupKey, + shortcuts, + isFirst, +}: { + groupKey: string; + shortcuts: Array; + isFirst: boolean; +}) { + const localize = useLocalize(); + return ( +
+

+ {localize(groupKey as TranslationKeys)} +

+ {shortcuts.map((shortcut) => ( + + ))} +
+ ); +} + function KeyboardShortcutsDialog() { const localize = useLocalize(); const [open, setOpen] = useRecoilState(store.showShortcutsDialog); @@ -60,48 +86,52 @@ function KeyboardShortcutsDialog() { const groupEntries = useMemo(() => Object.entries(grouped), [grouped]); + const leftColumn = useMemo( + () => groupEntries.filter(([key]) => key !== 'com_shortcut_group_chat'), + [groupEntries], + ); + const rightColumn = useMemo( + () => groupEntries.filter(([key]) => key === 'com_shortcut_group_chat'), + [groupEntries], + ); + return ( - -
- - {localize('com_shortcut_keyboard_shortcuts')} - - + +
+ {localize('com_shortcut_keyboard_shortcuts')} + {localize('com_ui_close')}
-
- {groupEntries.map(([groupKey, shortcuts], groupIdx) => ( -
0 && - 'border-border-light/60 mt-3 border-t pt-3 dark:border-white/[0.06]', - )} - > -

- {localize(groupKey as TranslationKeys)} -

- {shortcuts.map((shortcut) => ( - - ))} -
- ))} +
+
+ {leftColumn.map(([groupKey, shortcuts], idx) => ( + + ))} +
+
+ {rightColumn.map(([groupKey, shortcuts], idx) => ( + + ))} +
-
+
- + {localize('com_shortcut_show_shortcuts')}