Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fix: Web - Split - Enter and CMD+Enter open user profile instead of splitting expense." #45964

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
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
26 changes: 3 additions & 23 deletions src/components/ButtonWithDropdownMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ 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';
Expand Down Expand Up @@ -34,7 +33,6 @@ function ButtonWithDropdownMenu<IValueType>({
onOptionSelected,
enterKeyEventListenerPriority = 0,
wrapperStyle,
useKeyboardShortcuts = false,
}: ButtonWithDropdownMenuProps<IValueType>) {
const theme = useTheme();
const styles = useThemeStyles();
Expand Down Expand Up @@ -67,34 +65,16 @@ function ButtonWithDropdownMenu<IValueType>({
});
}
}, [windowWidth, windowHeight, isMenuVisible, anchorAlignment.vertical]);

useKeyboardShortcut(
CONST.KEYBOARD_SHORTCUTS.CTRL_ENTER,
(e) => {
onPress(e, selectedItem.value);
},
{
captureOnInputs: true,
shouldBubble: false,
isActive: useKeyboardShortcuts,
},
);

useEffect(() => {
if (!!caretButton.current || !buttonRef?.current || !(shouldAlwaysShowDropdownMenu || options.length > 1)) {
return;
}
caretButton.current = buttonRef.current;
}, [buttonRef, options.length, shouldAlwaysShowDropdownMenu]);

return (
<View style={wrapperStyle}>
{shouldAlwaysShowDropdownMenu || options.length > 1 ? (
<View style={[styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, style]}>
<Button
success={success}
pressOnEnter={pressOnEnter}
ref={buttonRef}
ref={(ref) => {
caretButton.current = ref;
}}
onPress={(event) => (!isSplitButton ? setIsMenuVisible(!isMenuVisible) : onPress(event, selectedItem.value))}
text={customText ?? selectedItem.text}
isDisabled={isDisabled || !!selectedItem.disabled}
Expand Down
3 changes: 0 additions & 3 deletions src/components/ButtonWithDropdownMenu/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ type ButtonWithDropdownMenuProps<TValueType> = {

/** Whether the button should use split style or not */
isSplitButton?: boolean;

/** Whether to use keyboard shortcuts for confirmation or not */
useKeyboardShortcuts?: boolean;
};

export type {
Expand Down
3 changes: 0 additions & 3 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,6 @@ function MoneyRequestConfirmationList({
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM,
}}
enterKeyEventListenerPriority={1}
useKeyboardShortcuts
/>
) : (
<ButtonWithDropdownMenu
Expand All @@ -790,7 +789,6 @@ function MoneyRequestConfirmationList({
options={splitOrRequestOptions}
buttonSize={CONST.DROPDOWN_BUTTON_SIZE.LARGE}
enterKeyEventListenerPriority={1}
useKeyboardShortcuts
/>
);

Expand Down Expand Up @@ -885,7 +883,6 @@ function MoneyRequestConfirmationList({
footerContent={footerContent}
listFooterContent={listFooterContent}
containerStyle={[styles.flexBasisAuto]}
disableKeyboardShortcuts
removeClippedSubviews={false}
/>
</MouseProvider>
Expand Down
9 changes: 1 addition & 8 deletions src/components/SettlementButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ type SettlementButtonProps = SettlementButtonOnyxProps & {

/** Callback to open confirmation modal if any of the transactions is on HOLD */
confirmApproval?: () => void;

/** Whether to use keyboard shortcuts for confirmation or not */
useKeyboardShortcuts?: boolean;
};

function SettlementButton({
Expand Down Expand Up @@ -143,7 +140,6 @@ function SettlementButton({
enterKeyEventListenerPriority = 0,
confirmApproval,
policy,
useKeyboardShortcuts = false,
}: SettlementButtonProps) {
const {translate} = useLocalize();
const {isOffline} = useNetwork();
Expand Down Expand Up @@ -287,14 +283,11 @@ function SettlementButton({
onPress={(event, iouPaymentType) => selectPaymentType(event, iouPaymentType, triggerKYCFlow)}
pressOnEnter={pressOnEnter}
options={paymentButtonOptions}
onOptionSelected={(option) => {
savePreferredPaymentMethod(policyID, option.value);
}}
onOptionSelected={(option) => savePreferredPaymentMethod(policyID, option.value)}
style={style}
buttonSize={buttonSize}
anchorAlignment={paymentMethodDropdownAnchorAlignment}
enterKeyEventListenerPriority={enterKeyEventListenerPriority}
useKeyboardShortcuts={useKeyboardShortcuts}
/>
)}
</KYCWall>
Expand Down
Loading