From 35c496808d43c8010df22522419b4dfa2569f154 Mon Sep 17 00:00:00 2001 From: mkhutornyi Date: Wed, 29 Nov 2023 12:51:55 +0100 Subject: [PATCH] prevent auto submit form on enter key press in selection modal --- src/hooks/useKeyboardShortcut.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/hooks/useKeyboardShortcut.ts b/src/hooks/useKeyboardShortcut.ts index a5921ba37e4a..461f01a74837 100644 --- a/src/hooks/useKeyboardShortcut.ts +++ b/src/hooks/useKeyboardShortcut.ts @@ -18,6 +18,8 @@ type KeyboardShortcutConfig = { excludedNodes?: string[]; /* Is keyboard shortcut is already active */ isActive?: boolean; + /* Shuld stop propagation? */ + shouldStopPropagation?: boolean; }; /** @@ -35,6 +37,9 @@ export default function useKeyboardShortcut(shortcut: Shortcut, callback: (e?: G // Hence the use of CONST.EMPTY_ARRAY. excludedNodes = CONST.EMPTY_ARRAY, isActive = true, + + // This flag is used to prevent auto submit form when press enter key on selection modal. + shouldStopPropagation = false, } = config; useEffect(() => { @@ -52,6 +57,7 @@ export default function useKeyboardShortcut(shortcut: Shortcut, callback: (e?: G priority, shouldPreventDefault, excludedNodes as string[], + shouldStopPropagation, ); return () => {