From 305057b2cabae0d5a377d660b303aa19ecba7a6b Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Fri, 26 Jul 2024 16:47:29 +0530 Subject: [PATCH 1/2] fix: Split - Enter and CMD+Enter open user profile instead of splitting expense. Signed-off-by: krishna2323 --- .../ButtonWithDropdownMenu/index.tsx | 20 ++++++++++++++++--- .../ButtonWithDropdownMenu/types.ts | 3 +++ .../MoneyRequestConfirmationList.tsx | 3 +++ src/components/SettlementButton.tsx | 5 +++++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/components/ButtonWithDropdownMenu/index.tsx b/src/components/ButtonWithDropdownMenu/index.tsx index 094c26a2b38..ae602ab5004 100644 --- a/src/components/ButtonWithDropdownMenu/index.tsx +++ b/src/components/ButtonWithDropdownMenu/index.tsx @@ -4,10 +4,12 @@ import Button from '@components/Button'; import Icon from '@components/Icon'; import * as Expensicons from '@components/Icon/Expensicons'; import PopoverMenu from '@components/PopoverMenu'; +import useKeyboardShortcut from '@hooks/useKeyboardShortcut'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; +import mergeRefs from '@libs/mergeRefs'; import CONST from '@src/CONST'; import type {AnchorPosition} from '@src/styles'; import type {ButtonWithDropdownMenuProps} from './types'; @@ -33,6 +35,7 @@ function ButtonWithDropdownMenu({ onOptionSelected, enterKeyEventListenerPriority = 0, wrapperStyle, + useKeyboardShortcuts = false, }: ButtonWithDropdownMenuProps) { const theme = useTheme(); const styles = useThemeStyles(); @@ -65,6 +68,19 @@ function ButtonWithDropdownMenu({ }); } }, [windowWidth, windowHeight, isMenuVisible, anchorAlignment.vertical]); + + useKeyboardShortcut( + CONST.KEYBOARD_SHORTCUTS.CTRL_ENTER, + (e) => { + onPress(e, selectedItem.value); + }, + { + captureOnInputs: true, + shouldBubble: false, + isActive: useKeyboardShortcuts, + }, + ); + return ( {shouldAlwaysShowDropdownMenu || options.length > 1 ? ( @@ -72,9 +88,7 @@ function ButtonWithDropdownMenu({