Skip to content

Commit

Permalink
Merge pull request #4064 from glo71317/PWA-3065
Browse files Browse the repository at this point in the history
Pwa 3065::When the button "sign in" is pressed by the keyboard, nothing happens.
  • Loading branch information
glo82145 authored Mar 24, 2023
2 parents 1e420d3 + c36d345 commit 32307d4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ test('returns correct shape', () => {
"shouldRender": false,
},
"setFormApi": [Function],
"signinHandleEnterKeyPress": [Function],
}
`);
});
Expand Down
10 changes: 10 additions & 0 deletions packages/peregrine/lib/talons/SignIn/useSignIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const useSignIn = props => {
},
...recaptchaData
});

const token = signInResponse.data.generateCustomerToken.token;
await setToken(token);

Expand Down Expand Up @@ -173,6 +174,14 @@ export const useSignIn = props => {
};
}, [handleCreateAccount]);

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

const errors = useMemo(
() =>
new Map([
Expand All @@ -186,6 +195,7 @@ export const useSignIn = props => {
errors,
handleCreateAccount,
handleEnterKeyPress,
signinHandleEnterKeyPress,
handleForgotPassword,
handleSubmit,
isBusy: isGettingDetails || isSigningIn || recaptchaLoading,
Expand Down
2 changes: 2 additions & 0 deletions packages/venia-ui/lib/components/SignIn/signIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const SignIn = props => {
errors,
handleCreateAccount,
handleEnterKeyPress,
signinHandleEnterKeyPress,
handleForgotPassword,
handleSubmit,
isBusy,
Expand Down Expand Up @@ -119,6 +120,7 @@ const SignIn = props => {
<Button
priority="high"
type="submit"
onKeyDown={signinHandleEnterKeyPress}
data-cy="SignInButton-root_highPriority"
disabled={isBusy}
>
Expand Down

0 comments on commit 32307d4

Please sign in to comment.