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

BUG#-3064 When the button cancel beside create account is pressed by … #4049

Merged
merged 9 commits into from
Mar 23, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Object {
"signInMutation" => null,
},
"handleCancel": [Function],
"handleCancelKeyPress": [Function],
"handleSubmit": [Function],
"initialValues": Object {
"customer": Object {
Expand Down
10 changes: 10 additions & 0 deletions packages/peregrine/lib/talons/CreateAccount/useCreateAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ export const useCreateAccount = props => {
onCancel();
}, [onCancel]);

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

const handleSubmit = useCallback(
async formValues => {
setIsSubmitting(true);
Expand Down Expand Up @@ -167,6 +175,7 @@ export const useCreateAccount = props => {
setIsSubmitting(false);
}
},

[
cartId,
generateReCaptchaData,
Expand Down Expand Up @@ -209,6 +218,7 @@ export const useCreateAccount = props => {
errors,
handleCancel,
handleSubmit,
handleCancelKeyPress,
initialValues: sanitizedInitialValues,
isDisabled: isSubmitting || isGettingDetails || recaptchaLoading,
recaptchaWidgetProps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const CreateAccount = props => {
handleCancel,
handleSubmit,
handleEnterKeyPress,
handleCancelKeyPress,
isDisabled,
initialValues,
recaptchaWidgetProps
Expand All @@ -47,6 +48,7 @@ const CreateAccount = props => {
type="button"
priority="low"
onClick={handleCancel}
onKeyDown={handleCancelKeyPress}
>
<FormattedMessage
id={'createAccount.cancelText'}
Expand Down