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

AC-6677::The button seems to not be working with the keyboard. When the ENTER key is pressed, nothing is happening #3973

Merged
merged 6 commits into from
Nov 14, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Object {
"value": 40,
},
},
"handleEnterKeyPress": [Function],
"handleProceedToCheckout": [Function],
"hasError": false,
"hasItems": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,17 @@ export const usePriceSummary = (props = {}) => {
history.push('/checkout');
}, [history]);

const handleEnterKeyPress = useCallback(() => {
event => {
if (event.key === 'Enter') {
handleProceedToCheckout();
}
};
}, [handleProceedToCheckout]);

return {
handleProceedToCheckout,
handleEnterKeyPress,
hasError: !!error,
hasItems: data && !!data.cart.items.length,
isCheckout,
Expand Down Expand Up @@ -111,6 +120,7 @@ export const usePriceSummary = (props = {}) => {
* @typedef {Object} PriceSummaryTalonProps
*
* @property {function} handleProceedToCheckout Callback function which navigates the browser to the checkout
* * @property {function} handleEnterKeyPress Callback function which navigates the browser to the checkout at the press of enter key
* @property {boolean} hasError True if a GraphQL query returns an error. False otherwise.
* @property {boolean} hasItems True if the cart has any items. False otherwise.
* @property {boolean} isLoading True while the GraphQL query is still in flight. False otherwise.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ exports[`renders PriceSummary correctly on cart page 1`] = `
className="root_highPriority"
disabled={false}
onDragStart={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseDown={[Function]}
onMouseEnter={[Function]}
Expand Down Expand Up @@ -278,7 +277,6 @@ exports[`renders summary with loading state if query is loading 1`] = `
className="root_highPriority"
disabled={true}
onDragStart={[Function]}
onKeyDown={[Function]}
onKeyUp={[Function]}
onMouseDown={[Function]}
onMouseEnter={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const PriceSummary = props => {

const {
handleProceedToCheckout,
handleEnterKeyPress,
hasError,
hasItems,
isCheckout,
Expand Down Expand Up @@ -90,6 +91,7 @@ const PriceSummary = props => {
disabled={isPriceUpdating}
priority={'high'}
onClick={handleProceedToCheckout}
onKeyDown={handleEnterKeyPress}
data-cy="PriceSummary-checkoutButton"
>
<FormattedMessage
Expand Down