diff --git a/packages/peregrine/lib/talons/CheckoutPage/__tests__/__snapshots__/useCheckoutPage.spec.js.snap b/packages/peregrine/lib/talons/CheckoutPage/__tests__/__snapshots__/useCheckoutPage.spec.js.snap index f209f578f6..df9b26fcf9 100644 --- a/packages/peregrine/lib/talons/CheckoutPage/__tests__/__snapshots__/useCheckoutPage.spec.js.snap +++ b/packages/peregrine/lib/talons/CheckoutPage/__tests__/__snapshots__/useCheckoutPage.spec.js.snap @@ -13,6 +13,7 @@ Object { "error": undefined, "guestSignInUsername": "", "handlePlaceOrder": [Function], + "handlePlaceOrderEnterKeyPress": [Function], "handleReviewOrder": [Function], "handleReviewOrderEnterKeyPress": [Function], "hasError": false, diff --git a/packages/peregrine/lib/talons/CheckoutPage/useCheckoutPage.js b/packages/peregrine/lib/talons/CheckoutPage/useCheckoutPage.js index 617249044b..e084d05794 100644 --- a/packages/peregrine/lib/talons/CheckoutPage/useCheckoutPage.js +++ b/packages/peregrine/lib/talons/CheckoutPage/useCheckoutPage.js @@ -40,6 +40,7 @@ export const CHECKOUT_STEP = { * customer: Object, * error: ApolloError, * handlePlaceOrder: Function, + * handlePlaceOrderEnterKeyPress: Function, * hasError: Boolean, * isCartEmpty: Boolean, * isGuestCheckout: Boolean, @@ -250,6 +251,14 @@ export const useCheckoutPage = (props = {}) => { setIsPlacingOrder(true); }, [cartId, getOrderDetails]); + const handlePlaceOrderEnterKeyPress = useCallback(() => { + event => { + if (event.key === 'Enter') { + handlePlaceOrder(); + } + }; + }, [handlePlaceOrder]); + const [, { dispatch }] = useEventingContext(); // Go back to checkout if shopper logs in @@ -386,6 +395,7 @@ export const useCheckoutPage = (props = {}) => { error: checkoutError, guestSignInUsername, handlePlaceOrder, + handlePlaceOrderEnterKeyPress, hasError: !!checkoutError, isCartEmpty: !(checkoutData && checkoutData?.cart?.total_quantity), isGuestCheckout: !isSignedIn, diff --git a/packages/venia-ui/lib/components/CheckoutPage/checkoutPage.js b/packages/venia-ui/lib/components/CheckoutPage/checkoutPage.js index 15d43d07f5..cb319f4d5f 100644 --- a/packages/venia-ui/lib/components/CheckoutPage/checkoutPage.js +++ b/packages/venia-ui/lib/components/CheckoutPage/checkoutPage.js @@ -52,6 +52,7 @@ const CheckoutPage = props => { error, guestSignInUsername, handlePlaceOrder, + handlePlaceOrderEnterKeyPress, hasError, isCartEmpty, isGuestCheckout, @@ -272,6 +273,7 @@ const CheckoutPage = props => { checkoutStep === CHECKOUT_STEP.REVIEW ? (