From a3442906b2116400e64645bfff164e873a654976 Mon Sep 17 00:00:00 2001 From: Michael Gartner Date: Tue, 30 Jun 2026 16:30:20 -0600 Subject: [PATCH] Allow bookmarks without shortcuts --- src/components/QuickSwitcherDialog.tsx | 14 +++++---- src/components/QuickSwitcherSettings.tsx | 37 ++++++++++++++---------- src/index.ts | 2 +- src/quickSwitcher.tsx | 19 ++++++++---- src/types/quickSwitcher.ts | 2 +- src/utils/quickSwitcher.ts | 6 ++-- tests/quickSwitcher.test.ts | 14 ++++++++- 7 files changed, 61 insertions(+), 33 deletions(-) diff --git a/src/components/QuickSwitcherDialog.tsx b/src/components/QuickSwitcherDialog.tsx index f9bf2be..3819a7b 100644 --- a/src/components/QuickSwitcherDialog.tsx +++ b/src/components/QuickSwitcherDialog.tsx @@ -137,12 +137,14 @@ const QuickSwitcherDialog = ({ icon="document-open" key={bookmark.id} labelElement={ - - {formatShortcutForDisplay({ - shortcut: bookmark.shortcut, - isMac, - })} - + bookmark.shortcut ? ( + + {formatShortcutForDisplay({ + shortcut: bookmark.shortcut, + isMac, + })} + + ) : undefined } multiline onClick={(): void => onOpenBookmark(bookmark)} diff --git a/src/components/QuickSwitcherSettings.tsx b/src/components/QuickSwitcherSettings.tsx index 6cdc2fe..65af9d4 100644 --- a/src/components/QuickSwitcherSettings.tsx +++ b/src/components/QuickSwitcherSettings.tsx @@ -112,16 +112,21 @@ export const createQuickSwitcherSettingsComponent = ({ return; } - const normalizedShortcut = normalizeShortcut({ shortcut }); - if (!normalizedShortcut) { + const normalizedShortcut = shortcut + ? normalizeShortcut({ shortcut }) + : null; + if (shortcut && !normalizedShortcut) { showToast({ - content: "Capture a shortcut before adding", + content: "Capture a valid shortcut or leave it blank", intent: "warning", }); return; } - if (!shortcutHasModifier({ shortcut: normalizedShortcut })) { + if ( + normalizedShortcut && + !shortcutHasModifier({ shortcut: normalizedShortcut }) + ) { showToast({ content: "Shortcut must include at least one modifier key", intent: "warning", @@ -140,9 +145,9 @@ export const createQuickSwitcherSettingsComponent = ({ return; } - const existingShortcut = bookmarks.find( - (bookmark) => bookmark.shortcut === normalizedShortcut, - ); + const existingShortcut = normalizedShortcut + ? bookmarks.find((bookmark) => bookmark.shortcut === normalizedShortcut) + : null; if (existingShortcut) { showToast({ content: `Shortcut already used by "${existingShortcut.title}"`, @@ -196,12 +201,12 @@ export const createQuickSwitcherSettingsComponent = ({ @@ -227,12 +232,14 @@ export const createQuickSwitcherSettingsComponent = ({
- - {formatShortcutForDisplay({ - shortcut: bookmark.shortcut, - isMac, - })} - + {bookmark.shortcut ? ( + + {formatShortcutForDisplay({ + shortcut: bookmark.shortcut, + isMac, + })} + + ) : null}