diff --git a/packages/web/components/templates/KeyboardShortcutListModal.tsx b/packages/web/components/templates/KeyboardShortcutListModal.tsx index 3c9076a30..9ba255933 100644 --- a/packages/web/components/templates/KeyboardShortcutListModal.tsx +++ b/packages/web/components/templates/KeyboardShortcutListModal.tsx @@ -18,6 +18,7 @@ import { highlightBarKeyboardCommands, articleKeyboardCommands, } from '../../lib/keyboardShortcuts/navigationShortcuts' +import { useRouter } from 'next/router' type KeyboardShortcutListModalProps = { onOpenChange: (open: boolean) => void @@ -26,6 +27,8 @@ type KeyboardShortcutListModalProps = { export function KeyboardShortcutListModal( props: KeyboardShortcutListModalProps ): JSX.Element { + const router = useRouter() + return ( @@ -71,7 +74,7 @@ export function KeyboardShortcutListModal( /> {})} + commands={articleKeyboardCommands(router, () => {})} /> { + articleKeyboardCommands(router, async (action) => { switch (action) { case 'openOriginalArticle': const url = props.article.url diff --git a/packages/web/lib/keyboardShortcuts/navigationShortcuts.ts b/packages/web/lib/keyboardShortcuts/navigationShortcuts.ts index 29c5eff7e..5d172f474 100644 --- a/packages/web/lib/keyboardShortcuts/navigationShortcuts.ts +++ b/packages/web/lib/keyboardShortcuts/navigationShortcuts.ts @@ -11,14 +11,10 @@ export function navigationCommands( shortcutKeyDescription: 'g then h', callback: () => router?.push('/home'), }, - // { - // shortcutKeys: ['g', 'd'], - // callback: () => router.push('/discover'), - // }, { - shortcutKeys: ['b|u'], + shortcutKeys: ['b'], actionDescription: 'Go back', - shortcutKeyDescription: 'b or u', + shortcutKeyDescription: 'b', callback: () => router?.back(), }, ] @@ -213,6 +209,7 @@ type ArticleKeyboardAction = | 'editLabels' export function articleKeyboardCommands( + router: NextRouter | undefined, actionHandler: (action: ArticleKeyboardAction) => void ): KeyboardCommand[] { return [ @@ -222,6 +219,12 @@ export function articleKeyboardCommands( shortcutKeyDescription: 'o', callback: () => actionHandler('openOriginalArticle'), }, + { + shortcutKeys: ['u'], + actionDescription: 'Back to library', + shortcutKeyDescription: 'u', + callback: () => router?.push('/home'), + }, { shortcutKeys: ['+'], actionDescription: 'Increase font size',