From 4d64f1dedecb588779a2cf6dabddbe1b2fc10aaa Mon Sep 17 00:00:00 2001 From: Vikrant Gupta Date: Mon, 8 Jul 2024 19:25:50 +0530 Subject: [PATCH] chore: better logging for duplicate keyboard shortcuts (#5425) * chore: better logging for duplicate keyboard shortcuts * chore: skip flaky test * fix: make the shortcut error silent in prod --- frontend/src/hooks/hotkeys/useKeyboardHotkeys.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/hooks/hotkeys/useKeyboardHotkeys.tsx b/frontend/src/hooks/hotkeys/useKeyboardHotkeys.tsx index 68e1bc7ae4..12b70fa68e 100644 --- a/frontend/src/hooks/hotkeys/useKeyboardHotkeys.tsx +++ b/frontend/src/hooks/hotkeys/useKeyboardHotkeys.tsx @@ -90,8 +90,14 @@ function KeyboardHotkeysProvider({ (keyCombination: string, callback: () => void): void => { if (!shortcuts.current[keyCombination]) { shortcuts.current[keyCombination] = callback; + } else if (process.env.NODE_ENV === 'development') { + throw new Error( + `This shortcut is already present in current scope :- ${keyCombination}`, + ); } else { - throw new Error('This shortcut is already present in current scope'); + console.error( + `This shortcut is already present in current scope :- ${keyCombination}`, + ); } }, [shortcuts],