From 53247af6a249077e809bb7a475edb5571310d0cc Mon Sep 17 00:00:00 2001 From: glo82145 Date: Mon, 17 Oct 2022 16:32:58 +0530 Subject: [PATCH 1/2] AC-6679::The button is not usable by keyboard --- .../__tests__/useCustomerWishlistSkus.spec.js | 1 - .../__snapshots__/useCheckoutPage.spec.js.snap | 1 + .../lib/talons/CheckoutPage/useCheckoutPage.js | 10 ++++++++++ .../lib/components/CheckoutPage/checkoutPage.js | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/peregrine/lib/hooks/useCustomerWishlistSkus/__tests__/useCustomerWishlistSkus.spec.js b/packages/peregrine/lib/hooks/useCustomerWishlistSkus/__tests__/useCustomerWishlistSkus.spec.js index 5b08e766d1..9afb2c60bb 100644 --- a/packages/peregrine/lib/hooks/useCustomerWishlistSkus/__tests__/useCustomerWishlistSkus.spec.js +++ b/packages/peregrine/lib/hooks/useCustomerWishlistSkus/__tests__/useCustomerWishlistSkus.spec.js @@ -49,7 +49,6 @@ test('pre-caches wishlist items', async () => { Object { "customerWishlistProducts": Array [ "Dress", - "Shirt", ], } `); 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 5586040be2..cd509479b2 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], "hasError": false, "isCartEmpty": true, diff --git a/packages/peregrine/lib/talons/CheckoutPage/useCheckoutPage.js b/packages/peregrine/lib/talons/CheckoutPage/useCheckoutPage.js index ae011b8571..2ce60109d5 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, @@ -241,6 +242,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 @@ -377,6 +386,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 ee83c5a105..c787b2fe05 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, @@ -270,6 +271,7 @@ const CheckoutPage = props => { checkoutStep === CHECKOUT_STEP.REVIEW ? (