Skip to content

Commit

Permalink
Merge pull request #32176 from mkhutornyi/fix-31689
Browse files Browse the repository at this point in the history
prevent auto submit form on enter key press in selection modal
  • Loading branch information
marcochavezf authored Nov 30, 2023
2 parents 9c3125f + 35c4968 commit 53f2f9f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/hooks/useKeyboardShortcut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type KeyboardShortcutConfig = {
excludedNodes?: string[];
/* Is keyboard shortcut is already active */
isActive?: boolean;
/* Shuld stop propagation? */
shouldStopPropagation?: boolean;
};

/**
Expand All @@ -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(() => {
Expand All @@ -52,6 +57,7 @@ export default function useKeyboardShortcut(shortcut: Shortcut, callback: (e?: G
priority,
shouldPreventDefault,
excludedNodes as string[],
shouldStopPropagation,
);

return () => {
Expand Down

0 comments on commit 53f2f9f

Please sign in to comment.