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}