Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions apps/mail/components/ui/ai-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -444,25 +444,9 @@ function AISidebar({ className }: AISidebarProps) {
},
});

useHotkeys(
'Meta+0',
() => {
setOpen(!open);
},
{
useKey: true,
},
);

useHotkeys(
'Control+0',
() => {
setOpen(!open);
},
{
useKey: true,
},
);
useHotkeys('Meta+0', () => {
setOpen(!open);
});

const handleNewChat = useCallback(() => {
chatState.setMessages([]);
Expand Down
8 changes: 2 additions & 6 deletions apps/mail/hooks/use-mail-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,8 @@ export function useMailNavigation({ items, containerRef, onNavigate }: UseMailNa
useHotkeys('ArrowDown', handleArrowDown, {
useKey: true,
});
useHotkeys('J', handleArrowDown, {
useKey: true,
});
useHotkeys('K', handleArrowUp, {
useKey: true,
});
useHotkeys('J', handleArrowDown);
useHotkeys('K', handleArrowUp);
Comment on lines +229 to +230
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Maintain consistency with other hotkey configurations.

The removal of { useKey: true } from the 'J' and 'K' hotkeys creates inconsistency with other hotkeys in the same file. The ArrowUp, ArrowDown, Enter, and Escape hotkeys still use this option, which prevents default browser behavior.

Consider either:

  1. Adding back the { useKey: true } option for consistency:
-  useHotkeys('J', handleArrowDown);
-  useHotkeys('K', handleArrowUp);
+  useHotkeys('J', handleArrowDown, { useKey: true });
+  useHotkeys('K', handleArrowUp, { useKey: true });
  1. Or removing it from all hotkeys for consistent behavior across the navigation system.

This ensures uniform behavior between equivalent shortcuts (J/ArrowDown and K/ArrowUp).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
useHotkeys('J', handleArrowDown);
useHotkeys('K', handleArrowUp);
useHotkeys('J', handleArrowDown, { useKey: true });
useHotkeys('K', handleArrowUp, { useKey: true });
🤖 Prompt for AI Agents
In apps/mail/hooks/use-mail-navigation.ts around lines 229 to 230, the hotkey
bindings for 'J' and 'K' lack the { useKey: true } option, causing inconsistency
with other hotkeys like ArrowUp and ArrowDown that include it to prevent default
browser behavior. To fix this, either add { useKey: true } back to the 'J' and
'K' hotkeys to match the existing pattern or remove this option from all hotkeys
to maintain consistent behavior across the navigation system.

useHotkeys('Enter', handleEnter, {
useKey: true,
});
Expand Down
2 changes: 0 additions & 2 deletions apps/mail/lib/hotkeys/use-hotkey-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ export function useShortcut(
...restOptions,
scopes: [scope],
preventDefault: shortcut.preventDefault || preventDefault,
useKey: true,
},
[handleKey],
);
Expand Down Expand Up @@ -283,7 +282,6 @@ export function useShortcuts(
preventDefault: false, // We'll handle preventDefault per-shortcut
keyup: false,
keydown: true,
useKey: true,
},
[shortcutMap, handlers, options],
);
Expand Down