Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,18 @@ export const useCommandMenuHotKeys = () => {

useGlobalHotkeys({
keys: ['ctrl+k', 'meta+k'],
callback: () => {
closeKeyboardShortcutMenu();
toggleCommandMenu();
callback: (e: KeyboardEvent) => {
const active = document.activeElement;
const isInEditor = active?.closest('.editor');
if (isInEditor !== null) {
return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider returning early with return instead of return true for consistency with other early returns in the codebase

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/twenty-front/src/modules/command-menu/hooks/useCommandMenuHotKeys.ts
Line: 52:52

Comment:
**style:** Consider returning early with `return` instead of `return true` for consistency with other early returns in the codebase

How can I resolve this? If you propose a fix, please make it concise.

}

if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'k') {
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Redundant condition check - the keys array already defines 'ctrl+k' and 'meta+k', so this manual key check is unnecessary

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/twenty-front/src/modules/command-menu/hooks/useCommandMenuHotKeys.ts
Line: 55:55

Comment:
**style:** Redundant condition check - the keys array already defines 'ctrl+k' and 'meta+k', so this manual key check is unnecessary

How can I resolve this? If you propose a fix, please make it concise.

e.preventDefault();
closeKeyboardShortcutMenu();
toggleCommandMenu();
}
Comment on lines +49 to +59

Choose a reason for hiding this comment

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

Potential bug: The useGlobalHotkeys hook prevents the default event action before the callback runs, blocking the editor's native ctrl+k shortcut from triggering.
  • Description: The useGlobalHotkeys hook for the ctrl+k shortcut is called without the preventDefault: false option. The hook's implementation stops the keyboard event's propagation and prevents its default action before the provided callback is executed. The callback logic, which checks if the user is inside an editor, runs too late to allow the event to proceed. As a consequence, the editor's native link insertion shortcut (ctrl+k) will not function, as the event is intercepted and stopped before it can reach the editor.

  • Suggested fix: Pass an options object with preventDefault: false to the useGlobalHotkeys hook. This ensures the callback executes before the event is handled. Then, inside the callback, manually call e.preventDefault() only when the condition to open the command menu is met (i.e., when not focused within the editor).
    severity: 0.65, confidence: 1.0

Did we get this right? 👍 / 👎 to inform future reviews.

},
containsModifier: true,
dependencies: [closeKeyboardShortcutMenu, toggleCommandMenu],
Expand Down